diff --git a/dist/admin/config.yml b/dist/admin/config.yml index 4afd370..bae4571 100644 --- a/dist/admin/config.yml +++ b/dist/admin/config.yml @@ -31,8 +31,8 @@ collections: folder: /src/pages extension: md format: yaml-frontmatter - create: false # the fixed page set; the site nav is static - delete: false # removing a page would break the nav mid-build + create: true # pages land in src/pages and appear in the nav (it is built from this folder) + delete: false # a page (the Home page above all) cannot be deleted from the CMS slug: "{{slug}}" identifier_field: title summary: "{{title}}" diff --git a/public/admin/config.yml b/public/admin/config.yml index 4afd370..bae4571 100644 --- a/public/admin/config.yml +++ b/public/admin/config.yml @@ -31,8 +31,8 @@ collections: folder: /src/pages extension: md format: yaml-frontmatter - create: false # the fixed page set; the site nav is static - delete: false # removing a page would break the nav mid-build + create: true # pages land in src/pages and appear in the nav (it is built from this folder) + delete: false # a page (the Home page above all) cannot be deleted from the CMS slug: "{{slug}}" identifier_field: title summary: "{{title}}" diff --git a/src/layouts/Site.astro b/src/layouts/Site.astro index a4393be..99d0671 100644 --- a/src/layouts/Site.astro +++ b/src/layouts/Site.astro @@ -1,8 +1,14 @@ --- -const pages = [ - { href: "/", label: "Home" }, - { href: "/about", label: "About" }, -]; +const pageFiles = import.meta.glob("../pages/**/*.md", { eager: true }); +const pages = Object.entries(pageFiles) + .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`. const { title } = Astro.props.frontmatter ?? Astro.props; ---