-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsvelte.config.js
More file actions
55 lines (49 loc) · 1.31 KB
/
Copy pathsvelte.config.js
File metadata and controls
55 lines (49 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import adapter from '@sveltejs/adapter-static';
import { readdir } from 'fs/promises';
import { join } from 'path';
import { getBasePath } from './src/lib/utils/paths.js';
async function createConfig() {
// Explicit, so the two endpoints have to be named: SvelteKit finds pages by
// crawling links, and nothing on the site links to a sitemap or to robots.txt.
const entries = [
'/',
'/projects',
'/list',
'/map',
'/about',
'/legal',
'/privacy',
'/sitemap.xml',
'/robots.txt'
];
try {
const projectsPath = join(process.cwd(), 'content/projects');
const projectFolders = await readdir(projectsPath);
for (const folder of projectFolders) {
if (folder.startsWith('.') || folder.endsWith('.zip')) continue;
entries.push(`/projects/${folder}`);
}
console.log(`Generated ${entries.length} prerender entries`);
} catch (error) {
console.error('Error generating entries:', error);
}
/** @type {import('@sveltejs/kit').Config} */
return {
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: '404.html',
precompress: false,
strict: true
}),
// Derived from siteConfig.url, the one place the address is written
paths: { base: getBasePath() },
prerender: {
handleHttpError: 'warn',
entries
}
}
};
}
export default await createConfig();