generate metadata for the documentation page
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 1m10s

This commit is contained in:
Lee 2024-04-20 00:50:59 +01:00
parent e8e74a1a8d
commit 57a45a4c05
3 changed files with 25 additions and 7 deletions

View File

@ -1,4 +1,4 @@
import createMDX from '@next/mdx'
import createMDX from "@next/mdx";
/** @type {import('next').NextConfig} */
const nextConfig = {

View File

@ -1,5 +1,13 @@
import { getDocumentation } from "@/common/documentation";
import { CustomMDX } from "@/app/components/mx-components";
import { Metadata } from "next";
import { generateEmbed } from "@/common/embed";
type DocumentationPageParams = {
params: {
slug?: string;
};
};
export async function generateStaticParams() {
let documentationPages = getDocumentation();
@ -9,11 +17,22 @@ export async function generateStaticParams() {
}));
}
type DocumentationPageParams = {
params: {
slug?: string;
};
};
export async function generateMetadata({ params: { slug } }: DocumentationPageParams): Promise<Metadata> {
const documentationPages = getDocumentation();
let page = documentationPages.find(page => page.slug === slug);
if (!page) {
return generateEmbed({
title: "Page not found",
description: "The documentation page was not found",
});
}
return generateEmbed({
title: page.metadata.title,
description: "Click to view this page",
});
}
export default function Page({ params: { slug } }: DocumentationPageParams) {
const documentationPages = getDocumentation();

View File

@ -1,6 +1,5 @@
import Image from "next/image";
import { ReactElement } from "react";
import config from "@root/config.json";
type LogoProps = {
/**