Skip to content

Commit b0cb8a4

Browse files
committed
chore: use new base option for import.meta.glob
1 parent 1efc7ee commit b0cb8a4

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

apps/svelte.dev/src/lib/server/content.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@ import { read } from '$app/server';
22
import type { Document, DocumentSummary } from '@sveltejs/site-kit';
33
import { 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

2321
const months = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
2422

packages/site-kit/src/lib/server/content/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,18 @@ import type { Document } from '../../types';
44
export 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(/(\/index)?\.md$/, '');
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) {

0 commit comments

Comments
 (0)