From e505cc92cf53e14db509500106adaf0e3f50c0f1 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Thu, 10 Oct 2024 14:34:52 -0700 Subject: [PATCH] feat: Custom extras page --- src/content/archives.md | 3 --- src/content/extra/archives.md | 6 ++++++ src/content/metadata.json | 5 ++++- src/lib/sitemap.ts | 5 +++-- src/routes/{archives => [slug]}/+page.svelte | 6 ++++-- src/routes/[slug]/+page.ts | 12 ++++++++++++ src/routes/archives/+page.ts | 11 ----------- 7 files changed, 29 insertions(+), 19 deletions(-) delete mode 100644 src/content/archives.md create mode 100644 src/content/extra/archives.md rename src/routes/{archives => [slug]}/+page.svelte (62%) create mode 100644 src/routes/[slug]/+page.ts delete mode 100644 src/routes/archives/+page.ts diff --git a/src/content/archives.md b/src/content/archives.md deleted file mode 100644 index c2a6133..0000000 --- a/src/content/archives.md +++ /dev/null @@ -1,3 +0,0 @@ -# Archives - -Archives live here diff --git a/src/content/extra/archives.md b/src/content/extra/archives.md new file mode 100644 index 0000000..1746531 --- /dev/null +++ b/src/content/extra/archives.md @@ -0,0 +1,6 @@ +--- +title: Archives Custom Title +--- +# Archives + +Archives live here diff --git a/src/content/metadata.json b/src/content/metadata.json index 3d9974a..64373f9 100644 --- a/src/content/metadata.json +++ b/src/content/metadata.json @@ -8,5 +8,8 @@ "github": "https://github.com", "email": "email:cirno@gensokyo.jp", "orcid": "https://orcid.org/cirno" - } + }, + "extra": [ + { "route": "/archives", "name": "Archives" } + ] } diff --git a/src/lib/sitemap.ts b/src/lib/sitemap.ts index 3b312b9..5dfcf30 100644 --- a/src/lib/sitemap.ts +++ b/src/lib/sitemap.ts @@ -1,7 +1,8 @@ +import siteMetadata from '$content/metadata.json'; + export const routes: { route: string, name: string, disabled?: boolean }[] = [ { route: "/", name: "Home" }, { route: "/post", name: "Blog" }, { route: "/tag", name: "Tags" }, { route: "/gallery", name: "Gallery", disabled: true }, - { route: "/archives", name: "Archives" }, -]; +].concat(siteMetadata?.extra || []); diff --git a/src/routes/archives/+page.svelte b/src/routes/[slug]/+page.svelte similarity index 62% rename from src/routes/archives/+page.svelte rename to src/routes/[slug]/+page.svelte index 8b15211..d175188 100644 --- a/src/routes/archives/+page.svelte +++ b/src/routes/[slug]/+page.svelte @@ -1,12 +1,14 @@ - Archives | {siteMetadata.blogName} + {title} | {siteMetadata.blogName}
diff --git a/src/routes/[slug]/+page.ts b/src/routes/[slug]/+page.ts new file mode 100644 index 0000000..dba9665 --- /dev/null +++ b/src/routes/[slug]/+page.ts @@ -0,0 +1,12 @@ +import type { PageLoad } from './$types'; + +export const load: PageLoad = async ({ params }) => { + const post = await import(`$content/extra/${params.slug}.md`); + const Content = post.default; + + return { + slug: params.slug, + metadata: post.metadata, + Content, + }; +} diff --git a/src/routes/archives/+page.ts b/src/routes/archives/+page.ts deleted file mode 100644 index efeea04..0000000 --- a/src/routes/archives/+page.ts +++ /dev/null @@ -1,11 +0,0 @@ -import type { PageLoad } from './$types'; - -export const load: PageLoad = async (_) => { - const post = await import("$content/archives.md"); - const Content = post.default; - - return { - metadata: post.metadata, - Content, - }; -}