Skip to content

Commit

Permalink
feat(frontend): add entries function
Browse files Browse the repository at this point in the history
This is to let the ssg know about all the dynamic routes that need to be prerendered.
  • Loading branch information
jmiguelv committed Jul 8, 2024
1 parent 002610e commit 1993e86
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions frontend/src/routes/inscription/[slug]/+page.server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { base } from '$app/paths';
import { error } from '@sveltejs/kit';
import fs from 'fs/promises';
import corpus from '../../../data/corpus.json';

/** @type {import('../$types').PageServerLoad} */
export async function load({ params }) {
Expand All @@ -27,3 +28,14 @@ export async function load({ params }) {
error(404, `Error loading ${params.slug}: ${e.message}`);
}
}

/**
* Returns an array of slugs derived from the corpus data.
* Each slug corresponds to a unique inscription file in the project.
*
* @returns {Array<{ slug: string }>} An array of objects, each containing a unique slug.
* @type {import('./$types').EntryGenerator}
*/
export function entries() {
return corpus.map(({ file: slug }) => ({ slug }));
}

0 comments on commit 1993e86

Please sign in to comment.