File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change
1
+ export const slugFromPath = ( path : string ) =>
2
+ path . match ( / ( [ \w - ] + ) \. ( s v e l t e \. m d | m d | s v x ) / i) ?. [ 1 ] ?? null ;
Original file line number Diff line number Diff line change
1
+ import type { EntryGenerator } from './$types' ;
2
+ import { slugFromPath } from '$lib/utils/SlugFromPath' ;
3
+
4
+ // https://kit.svelte.dev/docs/page-options#prerender-troubleshooting
5
+ export const entries : EntryGenerator = async ( ) => {
6
+ const modules = import . meta. glob ( `/src/blogs/*.{md,svx,svelte.md}` ) ;
7
+ const postPromises = Object . entries ( modules ) . map ( ( [ path , resolver ] ) =>
8
+ resolver ( ) . then (
9
+ ( post ) =>
10
+ ( {
11
+ slug : slugFromPath ( path ) ,
12
+ ...( post as unknown as App . MdsvexFile ) . metadata
13
+ } ) as App . BlogPost
14
+ )
15
+ ) ;
16
+
17
+ const posts = await Promise . all ( postPromises ) ;
18
+ return posts ;
19
+ } ;
20
+ export const prerender = true ;
You can’t perform that action at this time.
0 commit comments