enable page creation in the CMS (create: true) + dynamic nav (import.meta.glob over src/pages)
deploy / build-and-publish (push) Successful in 48s
deploy / build-and-publish (push) Successful in 48s
This commit is contained in:
Vendored
+2
-2
@@ -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}}"
|
||||||
|
|||||||
@@ -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
@@ -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;
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user