From b6f3fdd15e844dac4fdefe033890827688cdb070 Mon Sep 17 00:00:00 2001 From: itsfinniii <102350242+itsfinniii@users.noreply.github.com> Date: Fri, 20 Mar 2026 16:55:33 +0100 Subject: [PATCH] Add 'exists' flags to content types and set them --- astro/src/content/blogs/blogs.ts | 1 + astro/src/content/projects/projects.ts | 6 ++++++ astro/src/layouts/WebpageLayout.astro | 2 ++ astro/src/lib/pages.ts | 8 +++++++- astro/src/pages/[...route].astro | 16 ++++++++-------- astro/src/types/blogs/blog.d.ts | 2 ++ astro/src/types/photos/album.d.ts | 3 +++ astro/src/types/photos/category.d.ts | 1 + astro/src/types/photos/photo.d.ts | 2 ++ astro/src/types/projects/project.d.ts | 4 ++++ 10 files changed, 36 insertions(+), 9 deletions(-) diff --git a/astro/src/content/blogs/blogs.ts b/astro/src/content/blogs/blogs.ts index 6614d15..69db695 100644 --- a/astro/src/content/blogs/blogs.ts +++ b/astro/src/content/blogs/blogs.ts @@ -94,6 +94,7 @@ export async function getBlog(settings: GlobalSettings, route: string): Promise< const blog: BlogPost = { type: "BlogPost", + exists: true, id: blogRecord["id"], lastModified: new Date(), title: blogRecord["title"], diff --git a/astro/src/content/projects/projects.ts b/astro/src/content/projects/projects.ts index 724c106..24136fa 100644 --- a/astro/src/content/projects/projects.ts +++ b/astro/src/content/projects/projects.ts @@ -24,6 +24,9 @@ export async function getAllProjects(settings: GlobalSettings): Promise + + diff --git a/astro/src/lib/pages.ts b/astro/src/lib/pages.ts index fb46cf4..88c866e 100644 --- a/astro/src/lib/pages.ts +++ b/astro/src/lib/pages.ts @@ -22,6 +22,7 @@ export async function getPage(settings: GlobalSettings, route: string): Promise< pageType: "BlogIndex", page: { type: "BlogIndex", + exists: true, pageNumber: params["page"] !== undefined ? Number(params["page"]) : 1 } }; @@ -63,6 +64,7 @@ export async function getPage(settings: GlobalSettings, route: string): Promise< pageType: "ProjectIndex", page: { type: "ProjectIndex", + exists: true, pageNumber: params["page"] !== undefined ? Number(params["page"]) : 1 } }; @@ -93,7 +95,8 @@ export async function getPage(settings: GlobalSettings, route: string): Promise< route: route, pageType: "PhotoCategoryIndex", page: { - type: "PhotoCategoryIndex" + type: "PhotoCategoryIndex", + exists: true } }; } @@ -114,6 +117,7 @@ export async function getPage(settings: GlobalSettings, route: string): Promise< pageType: "PhotoCategory", page: { type: "PhotoCategory", + exists: true, category: params["category"], pageNumber: params["page"] !== undefined ? Number(params["page"]) : 1 } @@ -160,6 +164,8 @@ export async function getPage(settings: GlobalSettings, route: string): Promise< pageType: "Photo", page: { type: "PhotoPage", + exists: true, + id: photo!.id, photo: photo!.photo, text: photo!.text diff --git a/astro/src/pages/[...route].astro b/astro/src/pages/[...route].astro index 8fad759..ba4fa07 100644 --- a/astro/src/pages/[...route].astro +++ b/astro/src/pages/[...route].astro @@ -22,7 +22,7 @@ export async function getStaticPaths() { const settings = await getSettings(); const page = await getPage(settings, Astro.url.pathname); -if (page === null) { +if (page === null || page.page === null) { return new Response("Page not found.", { status: 404, statusText: "Not Found" @@ -30,16 +30,16 @@ if (page === null) { } --- -{ page.pageType === "Webpage" && ( +{ page.page.type === "Webpage" && page.page.exists && (