mirror of https://github.com/sveltejs/svelte
parent
12bcb25755
commit
24346cf253
@ -1,8 +0,0 @@
|
||||
// @ts-check
|
||||
import examples_data from '$lib/generated/examples-data.js';
|
||||
import { get_examples_list } from '$lib/server/examples/index.js';
|
||||
import { json } from '@sveltejs/kit';
|
||||
|
||||
export const GET = () => {
|
||||
return json(get_examples_list(examples_data));
|
||||
};
|
@ -1,26 +0,0 @@
|
||||
import examples_data from '$lib/generated/examples-data.js';
|
||||
import { get_example, get_examples_list } from '$lib/server/examples/index.js';
|
||||
import { error, json } from '@sveltejs/kit';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
export const GET = ({ params }) => {
|
||||
const examples = new Set(
|
||||
get_examples_list(examples_data)
|
||||
.map((category) => category.examples)
|
||||
.flat()
|
||||
.map((example) => example.slug)
|
||||
);
|
||||
|
||||
if (!examples.has(params.slug)) throw error(404, 'Example not found');
|
||||
|
||||
return json(get_example(examples_data, params.slug));
|
||||
};
|
||||
|
||||
export async function entries() {
|
||||
const examples_list = get_examples_list(examples_data);
|
||||
|
||||
return examples_list
|
||||
.map(({ examples }) => examples)
|
||||
.flatMap((val) => val.map(({ slug }) => ({ slug })));
|
||||
}
|
Loading…
Reference in new issue