Prerender in svelte.config.js

pull/8427/head
Puru Vijay 4 years ago
parent dcd6f3926c
commit 7990e70560

@ -1,8 +1,10 @@
// @ts-check
import fs from 'node:fs';
import { extract_frontmatter } from '../markdown';
import { extract_frontmatter } from '../markdown/index.js';
const base = '../../site/content/tutorial/';
const base = new URL('../../../../../../site/content/tutorial/', import.meta.url).pathname;
console.log(base);
/**
* @returns {import('./types').TutorialData}

@ -32,7 +32,7 @@
slug: chapter.slug,
section,
chapter,
prev
prev,
};
lookup.set(chapter.slug, obj);
@ -54,13 +54,13 @@
const clone = (file) => ({
name: file.name.replace(/.\w+$/, ''),
type: file.type,
source: file.content
source: file.content,
});
$: if (repl) {
completed = false;
repl.set({
components: data.tutorial.initial.map(clone)
components: data.tutorial.initial.map(clone),
});
}
@ -68,13 +68,13 @@
function reset() {
repl.update({
components: data.tutorial.initial.map(clone)
components: data.tutorial.initial.map(clone),
});
}
function complete() {
repl.update({
components: data.tutorial.complete.map(clone)
components: data.tutorial.complete.map(clone),
});
}
@ -153,16 +153,6 @@
{/if}
</div>
<!-- HACK: To prerender all tutorial pages -->
<div style="display: none">
{#each data.tutorials_list as { tutorials }}
{#each tutorials as { slug }}
<!-- svelte-ignore a11y-missing-content -->
<a href="/tutorial/{slug}" />
{/each}
{/each}
</div>
<style>
.tutorial-outer {
position: relative;

@ -1,4 +1,9 @@
// @ts-check
import adapter from '@sveltejs/adapter-auto';
import {
get_tutorial_data,
get_tutorial_list,
} from './src/lib/server/tutorial/get-tutorial-data.js';
/** @type {import('@sveltejs/kit').Config} */
export default {
@ -7,6 +12,12 @@ export default {
prerender: {
// TODO: REMOVE
handleMissingId: 'ignore',
entries: [
'*',
...get_tutorial_list(get_tutorial_data()).flatMap(({ tutorials }) =>
tutorials.map((tutorial) => /** @type {`/${string}`} */ ('/tutorial/' + tutorial.slug))
),
],
},
},
};

Loading…
Cancel
Save