refactor(index): remove authors and tags leftovers
This commit is contained in:
parent
6c7b8d823a
commit
a933186b87
3 changed files with 0 additions and 32 deletions
|
@ -9,8 +9,6 @@ const blog = defineCollection({
|
||||||
description: z.string(),
|
description: z.string(),
|
||||||
date: z.coerce.date(),
|
date: z.coerce.date(),
|
||||||
image: image().optional(),
|
image: image().optional(),
|
||||||
tags: z.array(z.string()).optional(),
|
|
||||||
authors: z.array(z.string()).optional(),
|
|
||||||
draft: z.boolean().optional(),
|
draft: z.boolean().optional(),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
@ -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));
|
|
||||||
}
|
|
|
@ -7,7 +7,6 @@ import TableOfContents from "@/components/TableOfContents.astro";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import Layout from "@/layouts/Layout.astro";
|
import Layout from "@/layouts/Layout.astro";
|
||||||
import { parseAuthors } from "@/lib/server-utils";
|
|
||||||
import { formatDate, readingTime } from "@/lib/utils";
|
import { formatDate, readingTime } from "@/lib/utils";
|
||||||
import { Icon } from "astro-icon/components";
|
import { Icon } from "astro-icon/components";
|
||||||
|
|
||||||
|
@ -48,8 +47,6 @@ const prevPost = getPrevPost(currentPostId);
|
||||||
|
|
||||||
const post = Astro.props;
|
const post = Astro.props;
|
||||||
const { Content, headings } = await render(post);
|
const { Content, headings } = await render(post);
|
||||||
|
|
||||||
const authors = await parseAuthors(post.data.authors ?? []);
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<Layout title={post.data.title} description={post.data.description}>
|
<Layout title={post.data.title} description={post.data.description}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue