From 4b5e61f98b686ef2a9d5cab895ccabfb37999600 Mon Sep 17 00:00:00 2001 From: Nathan Totten Date: Sun, 8 Oct 2023 17:09:30 -0400 Subject: [PATCH] page titles --- src/app/docs/[...slug]/page.tsx | 21 +++++++++++++++++++++ src/app/docs/articles/node-modules/page.tsx | 5 +++++ src/app/docs/policies/page.tsx | 5 +++++ src/app/layout.tsx | 6 ++---- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/app/docs/[...slug]/page.tsx b/src/app/docs/[...slug]/page.tsx index 5c6bc4e4..d8754f82 100644 --- a/src/app/docs/[...slug]/page.tsx +++ b/src/app/docs/[...slug]/page.tsx @@ -1,12 +1,33 @@ import { DocsLayout } from "@/components/DocsLayout"; import { getAllContent, getContentBySlug } from "@/lib/content"; import { compileMdx } from "@/lib/markdown/mdx"; +import { Metadata } from "next"; import { notFound } from "next/navigation"; interface ArticleFrontMatter { title: string; } +export async function generateMetadata({ + params, +}: { + params: { slug: string[] }; +}): Promise { + const result = await getContentBySlug({ + dir: "docs", + baseUrlPath: "/docs", + slug: params.slug, + }); + if (!result) { + return {}; + } + + const { data } = result; + return { + title: data.title, + }; +} + export default async function Page({ params }: { params: { slug: string[] } }) { const result = await getContentBySlug({ dir: "docs", diff --git a/src/app/docs/articles/node-modules/page.tsx b/src/app/docs/articles/node-modules/page.tsx index 9b78a273..6a31ed63 100644 --- a/src/app/docs/articles/node-modules/page.tsx +++ b/src/app/docs/articles/node-modules/page.tsx @@ -1,9 +1,14 @@ import { DocsLayout } from "@/components/DocsLayout"; import { Bundle } from "@/lib/interfaces"; import { readFile } from "fs/promises"; +import { Metadata } from "next"; import Link from "next/link"; import { join } from "path"; +export const metadata: Metadata = { + title: "Node Modules", +}; + export default async function Page() { const data = ( (await readFile(join(process.cwd(), "./bundles.json"), "utf-8").then( diff --git a/src/app/docs/policies/page.tsx b/src/app/docs/policies/page.tsx index cddff5d3..f697a13d 100644 --- a/src/app/docs/policies/page.tsx +++ b/src/app/docs/policies/page.tsx @@ -1,7 +1,12 @@ +import { Metadata } from "next"; import Link from "next/link"; import { DocsHeader } from "../../../components/DocsHeader"; import { getAllPolicies } from "../../../lib/policies"; +export const metadata: Metadata = { + title: "Policies", +}; + export default async function Page() { const policies = await getAllPolicies(); diff --git a/src/app/layout.tsx b/src/app/layout.tsx index aa965049..9449b26c 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -9,11 +9,9 @@ import { beVietnamProFont } from "../lib/fonts"; export const metadata: Metadata = { title: { - template: "%s - Docs", - default: "CacheAdvance - Never miss the cache again.", + template: "%s - Zuplo Docs", + default: "Zuplo", }, - description: - "Cache every single thing your app could ever do ahead of time, so your code never even has to run at all.", }; export default function RootLayout({