enable page creation in the CMS (create: true) + dynamic nav (import.meta.glob over src/pages)
deploy / build-and-publish (push) Successful in 48s

This commit is contained in:
2026-11-21 08:32:35 +01:00
parent 3ac81d5a52
commit 95af7107d0
3 changed files with 14 additions and 8 deletions
+2 -2
View File
@@ -31,8 +31,8 @@ collections:
folder: /src/pages folder: /src/pages
extension: md extension: md
format: yaml-frontmatter format: yaml-frontmatter
create: false # the fixed page set; the site nav is static create: true # pages land in src/pages and appear in the nav (it is built from this folder)
delete: false # removing a page would break the nav mid-build delete: false # a page (the Home page above all) cannot be deleted from the CMS
slug: "{{slug}}" slug: "{{slug}}"
identifier_field: title identifier_field: title
summary: "{{title}}" summary: "{{title}}"
+2 -2
View File
@@ -31,8 +31,8 @@ collections:
folder: /src/pages folder: /src/pages
extension: md extension: md
format: yaml-frontmatter format: yaml-frontmatter
create: false # the fixed page set; the site nav is static create: true # pages land in src/pages and appear in the nav (it is built from this folder)
delete: false # removing a page would break the nav mid-build delete: false # a page (the Home page above all) cannot be deleted from the CMS
slug: "{{slug}}" slug: "{{slug}}"
identifier_field: title identifier_field: title
summary: "{{title}}" summary: "{{title}}"
+10 -4
View File
@@ -1,8 +1,14 @@
--- ---
const pages = [ const pageFiles = import.meta.glob("../pages/**/*.md", { eager: true });
{ href: "/", label: "Home" }, const pages = Object.entries(pageFiles)
{ href: "/about", label: "About" }, .map(([file, mod]) => {
]; const slug = file.replace("../pages", "").replace(/\.md$/, "");
return {
href: slug === "/index" ? "/" : slug,
label: mod.frontmatter?.title ?? slug,
};
})
.sort((a, b) => a.href.localeCompare(b.href));
// Markdown pages hand their frontmatter to the layout as `frontmatter`. // Markdown pages hand their frontmatter to the layout as `frontmatter`.
const { title } = Astro.props.frontmatter ?? Astro.props; const { title } = Astro.props.frontmatter ?? Astro.props;
--- ---