diff --git a/packages/my-remark/index.ts b/packages/my-remark/index.ts index 8c3575e..8874275 100644 --- a/packages/my-remark/index.ts +++ b/packages/my-remark/index.ts @@ -14,6 +14,7 @@ export const normalizeFrontmatter: RemarkPlugin = () => { */ if (fm.homepage) { fm.layout = "homepage"; + fm.title = "Just Be"; } else if (!fm.layout) { fm.layout = "default"; } diff --git a/src/pages/[...slug].astro b/src/pages/[...slug].astro index fc776be..a78cfda 100644 --- a/src/pages/[...slug].astro +++ b/src/pages/[...slug].astro @@ -20,6 +20,7 @@ slug ??= HOME_SLUG; let html = ""; let layout = "default"; +let title = ""; if (!isULID(slug)) { slug = (await Astro.locals.runtime.env.KV_MAPPINGS.get(slug)) as string; @@ -45,6 +46,7 @@ if (isULID(slug)) { if (!content) return Astro.rewrite("/404"); const { code, metadata } = await Astro.locals.render(content); html = code; + title = metadata.frontmatter.title; // The slice here is a hack to remove the "@layouts/" and ".astro" from the layout name // so that the import below works correctly layout = metadata.frontmatter.layout.slice(9, -6); @@ -59,6 +61,6 @@ slug = slug === HOME_SLUG ? "" : slug; const Layout = (await import(`../layouts/${layout}.astro`)).default; --- - +