per-page metadata
All checks were successful
Deploy / deploy (ubuntu-latest, 2.44.0) (push) Successful in 52s

Took 14 minutes
This commit is contained in:
Braydon 2024-10-06 18:34:09 -04:00
parent 96b79d9995
commit cf6447e4c4
3 changed files with 86 additions and 66 deletions

View File

@ -5,69 +5,4 @@ summary: 'petentium usu tota noluisse errem elaboraret auctor.'
---
# Get started with Pulse App!
petentium usu tota noluisse errem elaboraret auctor.
petentium usu tota noluisse errem elaboraret auctor.
petentium usu tota noluisse errem elaboraret auctor.
petentium usu tota noluisse errem elaboraret auctor.
petentium usu tota noluisse errem elaboraret auctor.
petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
## petentium usu tota noluisse errem elaboraret auctor.
petentium usu tota noluisse errem elaboraret auctor.

View File

@ -10,6 +10,8 @@ import {
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";
import { capitalizeWords } from "@/lib/string";
import { Metadata } from "next";
import Embed from "@/components/embed";
/**
* The page to render the documentation markdown content.
@ -70,4 +72,37 @@ const DocsPage = async ({
</main>
);
};
export const generateMetadata = async ({
params,
}: {
params: Promise<{ slug: string[] }>;
}): Promise<Metadata> => {
const slug: string = (((await params).slug as string[]) || undefined)?.join(
"/"
); // The slug of the content
let embed: Metadata | undefined; // The content embed, if any
if (slug) {
const content: DocsContentMetadata | undefined = getDocsContent().find(
(metadata: DocsContentMetadata): boolean => metadata.slug === slug
); // Get the content based on the provided slug
if (content) {
return Embed({
title: content.title,
description: content.summary,
});
}
}
// Return the page embed
return (
embed ||
Embed({
title: "Documentation",
description:
"Need help with Pulse App? You've come to the right place!",
})
);
};
export default DocsPage;

50
src/components/embed.tsx Normal file
View File

@ -0,0 +1,50 @@
import { Metadata } from "next";
/**
* Props for an embed.
*/
type EmbedProps = {
/**
* The title of the embed.
*/
title: string;
/**
* The description of the embed.
*/
description: string;
/**
* The optional thumbnail image of the embed.
*/
thumbnail?: string;
};
/**
* An embed for a page.
*
* @param props the embed props
* @returns the embed jsx
*/
const Embed = ({
title,
description,
thumbnail = "",
}: EmbedProps): Metadata => {
return {
title: title,
openGraph: {
title: `${title}`,
description: description,
images: [
{
url: thumbnail,
},
],
},
twitter: {
card: "summary",
},
};
};
export default Embed;