Skip to content

Commit

Permalink
Render title
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph authored and gitbutler-client committed Sep 11, 2024
1 parent 5ea5923 commit e2821a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/my-remark/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/[...slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -59,6 +61,6 @@ slug = slug === HOME_SLUG ? "" : slug;
const Layout = (await import(`../layouts/${layout}.astro`)).default;
---

<Layout id={slug}>
<Layout id={slug} title={title}>
<Fragment set:html={html} />
</Layout>

0 comments on commit e2821a0

Please sign in to comment.