|
4 | 4 | import TextzeugenContent, { setTarget } from './TextzeugenContent.svelte';
|
5 | 5 | import { base } from '$app/paths';
|
6 | 6 | import { page } from '$app/stores';
|
7 |
| - import { replaceState } from '$app/navigation'; |
| 7 | + import { afterNavigate, replaceState } from '$app/navigation'; |
8 | 8 | import { iiif, teipb } from '$lib/constants';
|
9 | 9 |
|
10 | 10 | /** @type {import('./$types').PageData} */
|
|
66 | 66 | let localVerses = Array(data.content?.length).fill(`${data.thirties}.${data.verse}`);
|
67 | 67 | let localPages = Array(data.content?.length).fill([]);
|
68 | 68 | let currentIiif = Array(data.content?.length).fill({});
|
69 |
| - //fill the data from the load-function into the localPages array |
70 |
| - data.content?.forEach((c, i) => { |
71 |
| - c.meta.then((meta) => { |
72 |
| - localPages[i] = [...localPages[i], ...meta]; |
73 |
| - currentIiif[i] = meta[1]?.iiif; |
| 69 | +
|
| 70 | + afterNavigate(() => { |
| 71 | + //fill the data from the load-function into the localPages array |
| 72 | + data.content?.forEach((c, i) => { |
| 73 | + c.meta.then((meta) => { |
| 74 | + localPages[i] = [...meta]; |
| 75 | + meta |
| 76 | + .find((m) => m.active) |
| 77 | + ?.iiif.then((iiif) => { |
| 78 | + currentIiif[i] = iiif; |
| 79 | + }); |
| 80 | + }); |
74 | 81 | });
|
75 | 82 | });
|
76 | 83 |
|
|
79 | 86 | /** @type {number} */ i,
|
80 | 87 | /** @type {string} */ sigla
|
81 | 88 | ) => {
|
82 |
| - const indexCurrent = localPages[i].findIndex((p) => p.page === e.detail.id); |
| 89 | + const indexCurrent = localPages[i].findIndex((p) => p.id === e.detail.id); |
83 | 90 | localPages[i][indexCurrent]?.iiif.then((iiif) => {
|
84 | 91 | currentIiif[i] = iiif;
|
85 | 92 | });
|
86 | 93 | const createObject = (/** @type {string} */ id) => {
|
87 | 94 | return {
|
88 |
| - page: id, |
| 95 | + id: id, |
89 | 96 | tpData: fetch(`${teipb}/parts/${sigla}.xml/json?&view=page&id=${id}&odd=parzival.odd`).then(
|
90 | 97 | (r) => r.json()
|
91 | 98 | ),
|
|
0 commit comments