From a933186b87afb0417122490f590a9b9550989b15 Mon Sep 17 00:00:00 2001 From: z0x Date: Sun, 27 Apr 2025 11:17:29 -0400 Subject: [PATCH] refactor(index): remove authors and tags leftovers --- src/content.config.ts | 2 -- src/lib/server-utils.ts | 27 --------------------------- src/pages/blog/[...id].astro | 3 --- 3 files changed, 32 deletions(-) delete mode 100644 src/lib/server-utils.ts diff --git a/src/content.config.ts b/src/content.config.ts index 6c2f1e3..5519d5f 100644 --- a/src/content.config.ts +++ b/src/content.config.ts @@ -9,8 +9,6 @@ const blog = defineCollection({ description: z.string(), date: z.coerce.date(), image: image().optional(), - tags: z.array(z.string()).optional(), - authors: z.array(z.string()).optional(), draft: z.boolean().optional(), }), }); diff --git a/src/lib/server-utils.ts b/src/lib/server-utils.ts deleted file mode 100644 index 134cd45..0000000 --- a/src/lib/server-utils.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { getEntry } from "astro:content"; - -export async function parseAuthors(authors: string[]) { - if (!authors || authors.length === 0) return []; - - const parseAuthor = async (id: string) => { - try { - const author = await getEntry("authors", id); - return { - id, - name: author?.data?.name || id, - avatar: author?.data?.avatar || "/static/logo.png", - isRegistered: !!author, - }; - } catch (error) { - console.error(`Error fetching author with id ${id}:`, error); - return { - id, - name: id, - avatar: "/static/logo.png", - isRegistered: false, - }; - } - }; - - return await Promise.all(authors.map(parseAuthor)); -} diff --git a/src/pages/blog/[...id].astro b/src/pages/blog/[...id].astro index 1a790a6..bea9ec7 100644 --- a/src/pages/blog/[...id].astro +++ b/src/pages/blog/[...id].astro @@ -7,7 +7,6 @@ import TableOfContents from "@/components/TableOfContents.astro"; import { Button } from "@/components/ui/button"; import { Separator } from "@/components/ui/separator"; import Layout from "@/layouts/Layout.astro"; -import { parseAuthors } from "@/lib/server-utils"; import { formatDate, readingTime } from "@/lib/utils"; import { Icon } from "astro-icon/components"; @@ -48,8 +47,6 @@ const prevPost = getPrevPost(currentPostId); const post = Astro.props; const { Content, headings } = await render(post); - -const authors = await parseAuthors(post.data.authors ?? []); ---