initial commit
This commit is contained in:
commit
61511ed28c
28 changed files with 5210 additions and 0 deletions
18
src/pages/search-index.json.js
Normal file
18
src/pages/search-index.json.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { getCollection } from 'astro:content';
|
||||
|
||||
export async function GET() {
|
||||
const posts = await getCollection('blog');
|
||||
const searchIndex = posts.map(post => ({
|
||||
title: post.data.title,
|
||||
description: post.data.description,
|
||||
content: post.body,
|
||||
pubDate: post.data.pubDate,
|
||||
slug: post.slug
|
||||
}));
|
||||
|
||||
return new Response(JSON.stringify(searchIndex), {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue