feat: add new site
This commit is contained in:
parent
53738961bb
commit
532a32db68
27 changed files with 1198 additions and 1328 deletions
19
src/routes/blog/posts.json.ts
Normal file
19
src/routes/blog/posts.json.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import type { BlogPostFrontmatter, BlogPostMeta } from '../../types';
|
||||
|
||||
export async function GET() {
|
||||
const modules = import.meta.glob('./*.svx');
|
||||
const posts: BlogPostMeta[] = [];
|
||||
|
||||
const resolved = (await Promise.all(Object.values(modules).map((f) => f()))) as {
|
||||
metadata: BlogPostFrontmatter;
|
||||
}[];
|
||||
|
||||
resolved.forEach(({ metadata }, index) => {
|
||||
const path = Object.keys(modules)[index].replace('.svx', '');
|
||||
posts.push({ ...metadata, href: `blog/${path}` });
|
||||
});
|
||||
|
||||
return {
|
||||
body: { posts }
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue