diff --git a/components/ui/Types.tsx b/components/ui/Types.tsx index b62e0e55..778321f4 100644 --- a/components/ui/Types.tsx +++ b/components/ui/Types.tsx @@ -5,6 +5,7 @@ export interface MDFileContent { * @format textarea */ content: string; + title?: string; } export interface Template { diff --git a/loaders/denoLoader.ts b/loaders/denoLoader.ts index e90e4c3e..9ca70c7c 100644 --- a/loaders/denoLoader.ts +++ b/loaders/denoLoader.ts @@ -1,6 +1,7 @@ import { MDFileContent } from "deco-sites/starting/components/ui/Types.tsx"; import type { LoaderContext } from "deco/types.ts"; import { redirect } from "deco/mod.ts"; +import { getTitleForPost } from "deco-sites/starting/docs/toc.ts"; /** @title {{{path}}} */ export interface Doc { @@ -9,6 +10,7 @@ export interface Doc { * @format textarea */ content: string; + title?: string; } const loader = async ( @@ -38,11 +40,11 @@ const loader = async ( const doc = props.docs?.find((doc) => doc.path === slug); if (doc) { - return { content: doc.content }; + return { content: doc.content, title: doc.title }; } const fileContent = await Deno.readTextFile(url); - return { content: fileContent }; + return { content: fileContent, title: getTitleForPost(language, documentSlug) }; }; export default loader; diff --git a/sections/CustomizableContent.tsx b/sections/CustomizableContent.tsx index 47725545..08b47ec2 100644 --- a/sections/CustomizableContent.tsx +++ b/sections/CustomizableContent.tsx @@ -89,7 +89,7 @@ export default function CustomizableMarkdownContent( {matchCustom?.content ? matchCustom.content.map((c) => ) - : } + : } ); } diff --git a/sections/MarkdownContent.tsx b/sections/MarkdownContent.tsx index 73e22dce..faa43caf 100644 --- a/sections/MarkdownContent.tsx +++ b/sections/MarkdownContent.tsx @@ -29,10 +29,14 @@ export default function DocsPage( if (attrs?.description) { description = String(attrs.description); } - return ( <> + + {props.data.title + ? `${props.data.title} | deco.cx docs` + : "deco.cx docs"} + {description && }