Skip to content

Commit

Permalink
add data route for fassungen
Browse files Browse the repository at this point in the history
(not fully working yet)
  • Loading branch information
Sebastian Flick committed Nov 2, 2024
1 parent aae7d5c commit 6ff98b3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/routes/fassungen/data/[thirties]/+server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { json } from '@sveltejs/kit';
import { api, teipb } from '$lib/constants';

/** @type {import('./$types').RequestHandler} */
export async function GET({ params, fetch }) {
const { hyparchetypes } = await fetch(`${api}/json/metadata-nomenclature.json`).then((r) =>
r.json()
);
const teipbData = await hyparchetypes.map(async (h) => {
const r = await fetch(
`${teipb}/parts/syn${params.thirties}.xml/json?&view=single&odd=parzival-verse.odd&xpath=//div[@subtype=%27${h.handle.replace('*', '')}%27]`
);
if (!r.ok) {
console.log('Failed to fetch tpData', r);
return false;
}
return r.json();
});
return json(await teipbData);
}

/** @type {import('./$types').EntryGenerator} */
export async function entries() {
const entriesArray = Array.from({ length: 827 }, (_, i) => ({ thirties: i + 1 }));
return entriesArray;
}

export const prerender = true;

0 comments on commit 6ff98b3

Please sign in to comment.