aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/blog/_posts/+page.server.ts
blob: bc9d5d9d19b592483ce967527db84b8c384debe7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { parsePost, type Post } from '$/lib/blog/Post.svelte'

const posts = import.meta.glob("../posts/*.svx") as Record<string, () => Promise<Post>>
const returnedData = Promise.all(Object.entries(posts).map(v => v[1]().then(r => [v[0], {
  ...parsePost(r as Post),
  default: null,
}] as const)));

export const load = async () => {
  return {
    posts: Object.fromEntries(await returnedData)
  }
}