File tree Expand file tree Collapse file tree 2 files changed +12
-16
lines changed
apps/svelte.dev/src/lib/server
packages/site-kit/src/lib/server/content Expand file tree Collapse file tree 2 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -2,23 +2,21 @@ import { read } from '$app/server';
22import type { Document , DocumentSummary } from '@sveltejs/site-kit' ;
33import { create_index } from '@sveltejs/site-kit/server/content' ;
44
5- const documents = import . meta. glob < string > ( '../../../content/**/*.md' , {
5+ const documents = import . meta. glob < string > ( '**/*.md' , {
6+ base : '../../../content' ,
67 eager : true ,
78 query : '?url' ,
89 import : 'default'
910} ) ;
1011
11- const assets = import . meta. glob < string > (
12- [ '../../../content/**/+assets/**' , '../../../content/**/+assets/**/.env' ] ,
13- {
14- eager : true ,
15- query : '?url' ,
16- import : 'default'
17- }
18- ) ;
12+ const assets = import . meta. glob < string > ( [ '**/+assets/**' , '**/+assets/**/.env' ] , {
13+ base : '../../../content' ,
14+ eager : true ,
15+ query : '?url' ,
16+ import : 'default'
17+ } ) ;
1918
20- // https://github.com/vitejs/vite/issues/17453
21- export const index = await create_index ( documents , assets , '../../../content' , read ) ;
19+ export const index = await create_index ( documents , assets , read ) ;
2220
2321const months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec' . split ( ' ' ) ;
2422
Original file line number Diff line number Diff line change @@ -4,20 +4,18 @@ import type { Document } from '../../types';
44export async function create_index (
55 documents : Record < string , string > ,
66 assets : Record < string , string > ,
7- base : string ,
87 read : ( asset : string ) => Response
98) : Promise < Record < string , Document > > {
109 const content : Record < string , Document > = { } ;
1110
1211 const roots : Document [ ] = [ ] ;
1312
14- for ( const key in documents ) {
15- if ( key . includes ( '+assets' ) ) continue ;
13+ for ( const file in documents ) {
14+ if ( file . includes ( '+assets' ) ) continue ;
1615
17- const file = key . slice ( base . length + 1 ) ;
1816 const slug = file . replace ( / ( ^ | \/ ) [ \d - ] + - / g, '$1' ) . replace ( / ( \/ i n d e x ) ? \. m d $ / , '' ) ;
1917
20- const text = await read ( documents [ key ] ) . text ( ) ;
18+ const text = await read ( documents [ file ] ) . text ( ) ;
2119 let { metadata, body } = extract_frontmatter ( text ) ;
2220
2321 if ( ! metadata . title ) {
You can’t perform that action at this time.
0 commit comments