svelte-migrate: renamed files
This commit is contained in:
parent
80b6e9976e
commit
a6d53167f7
14 changed files with 0 additions and 0 deletions
|
|
@ -1,25 +0,0 @@
|
|||
import type { BlogPostFrontmatter, BlogPostMeta } from '../../lib/utils/types';
|
||||
|
||||
const removeExtension = (path: string) => path.replace(/\.[^.]*$/g, '').replace('/index', '');
|
||||
|
||||
export async function GET() {
|
||||
const modulesSVX = import.meta.glob('./**/*.svx');
|
||||
const modulesMD = import.meta.glob('./**/*.md');
|
||||
const modules = { ...modulesMD, ...modulesSVX };
|
||||
const posts: BlogPostMeta[] = [];
|
||||
const resolved = (await Promise.all(Object.values(modules).map((f) => f()))) as {
|
||||
metadata: BlogPostFrontmatter;
|
||||
}[];
|
||||
resolved.forEach((file, index) => {
|
||||
const path = Object.keys(modules)[index];
|
||||
const { metadata } = file;
|
||||
|
||||
if (!metadata.hidden) posts.push({ ...metadata, href: `blog/${removeExtension(path)}` });
|
||||
});
|
||||
|
||||
posts.sort((a, b) => new Date(b.created).valueOf() - new Date(a.created).valueOf());
|
||||
|
||||
return {
|
||||
body: { posts },
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue