From 82e9f14eec5ad85353b794202b56696520704a6a Mon Sep 17 00:00:00 2001 From: Dinesh <13635627+HumbleBee14@users.noreply.github.com> Date: Tue, 14 Jul 2026 18:45:07 -0700 Subject: [PATCH] Resolve post/tool authors defensively: missing profile falls back to Guest instead of failing the build --- src/content/config.ts | 8 +++-- src/lib/posts.ts | 33 +++++++++++++++++-- .../authors/[handle]/articles/[...page].astro | 2 +- src/pages/authors/[handle]/index.astro | 2 +- src/pages/authors/index.astro | 2 +- src/pages/blog/[slug].astro | 5 +-- src/pages/og/post/[slug].png.ts | 5 +-- src/pages/playground/[tool].astro | 5 +-- 8 files changed, 47 insertions(+), 15 deletions(-) diff --git a/src/content/config.ts b/src/content/config.ts index 1d81e8e..6a67f0c 100644 --- a/src/content/config.ts +++ b/src/content/config.ts @@ -1,5 +1,5 @@ import { readdirSync } from 'node:fs'; -import { defineCollection, reference, z } from 'astro:content'; +import { defineCollection, z } from 'astro:content'; import { glob } from 'astro/loaders'; // Topic ids come from the data files themselves, so post frontmatter is @@ -31,7 +31,9 @@ const posts = defineCollection({ z.object({ title: z.string(), summary: z.string(), - authors: z.array(reference('authors')).min(1), + // Plain author handles, resolved defensively at render (see lib/posts.ts): + // a missing profile falls back to Guest rather than failing the build. + authors: z.array(z.string()).min(1), date: z.coerce.date(), readMin: z.number().int().positive(), // Display name is derived from topicId via topicName(); kept optional for @@ -62,7 +64,7 @@ const tools = defineCollection({ tag: z.enum(['Live', 'Beta', 'Experimental', 'Soon']), icon: z.string().optional(), thumbnail: z.union([image(), z.string().url()]).optional(), - authors: z.array(reference('authors')).optional(), + authors: z.array(z.string()).optional(), topics: z.array(z.string()).optional(), tags: z.array(z.string()).optional(), repo: z.string().url().optional(), diff --git a/src/lib/posts.ts b/src/lib/posts.ts index da14b82..aa5b103 100644 --- a/src/lib/posts.ts +++ b/src/lib/posts.ts @@ -1,15 +1,42 @@ // Server-only post helpers (astro:content cannot be bundled into client scripts — // keep this module out of anything imported by