From 5036d1145c73e1983d01782b5aff1d9b2f6b2445 Mon Sep 17 00:00:00 2001 From: Yufan Sheng Date: Fri, 15 Nov 2024 12:59:45 +0800 Subject: [PATCH] fix: revert the raw method in post for searching. --- src/helpers/schema.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/helpers/schema.ts b/src/helpers/schema.ts index 950f3ec..ff7c1c0 100644 --- a/src/helpers/schema.ts +++ b/src/helpers/schema.ts @@ -1,6 +1,6 @@ import { defaultCover } from '@/content/config.ts'; import options from '@/options'; -import { getCollection, type Render } from 'astro:content'; +import { getCollection, getEntry, type Render } from 'astro:content'; // Import the collections from the astro content. const categoriesCollection = await getCollection('categories'); @@ -24,6 +24,7 @@ export type Post = (typeof postsCollection)[number]['data'] & { slug: string; permalink: string; render: () => Render['.mdx']; + raw: () => Promise; }; export type Tag = (typeof tagsCollection)[number]['data'][number] & { counts: number; permalink: string }; @@ -44,6 +45,10 @@ export const posts: Post[] = postsCollection slug: post.slug, permalink: `/posts/${post.slug}`, render: post.render, + raw: async () => { + const entry = await getEntry('posts', post.slug); + return entry.body; + }, ...post.data, })) .sort((left: Post, right: Post) => {