narrative : fix data fetching (build URL from location)
All checks were successful
Deploy / Build and Deploy to Production (push) Successful in 17s

This commit is contained in:
isUnknown 2026-01-09 10:53:08 +01:00
parent ccaec7cfed
commit 4d1183d1af
2 changed files with 6 additions and 12 deletions

View file

@ -12,8 +12,6 @@ import Coloris from '@melloware/coloris';
const stylesheetStore = useStylesheetStore(); const stylesheetStore = useStylesheetStore();
const narrativeStore = useNarrativeStore(); const narrativeStore = useNarrativeStore();
// Get narrative URL from body data attribute (set by print.php template)
const narrativeUrl = document.body.dataset.narrativeUrl || null;
const previewFrame1 = ref(null); const previewFrame1 = ref(null);
const previewFrame2 = ref(null); const previewFrame2 = ref(null);
const elementPopup = ref(null); const elementPopup = ref(null);
@ -28,8 +26,6 @@ const selectedPages = ref([]); // Pages with active border (when popup is open)
const hoveredElement = ref(null); // Currently hovered content element const hoveredElement = ref(null); // Currently hovered content element
const selectedElement = ref(null); // Selected element (when popup is open) const selectedElement = ref(null); // Selected element (when popup is open)
const EDGE_THRESHOLD = 30; // px from edge to trigger hover const EDGE_THRESHOLD = 30; // px from edge to trigger hover
const PAGE_HIGHLIGHT_COLOR = '#ff8a50';
const ELEMENT_HIGHLIGHT_COLOR = '#7136ff';
let savedScrollPercentage = 0; let savedScrollPercentage = 0;
const currentFrameIndex = ref(1); // 1 or 2, which iframe is currently visible const currentFrameIndex = ref(1); // 1 or 2, which iframe is currently visible
@ -559,9 +555,7 @@ const printPreview = async () => {
onMounted(async () => { onMounted(async () => {
// Load narrative data if URL is provided (print mode) // Load narrative data if URL is provided (print mode)
if (narrativeUrl) { await narrativeStore.loadNarrative(location.href + '.json');
await narrativeStore.loadNarrative(narrativeUrl);
}
// Render preview after data is loaded // Render preview after data is loaded
renderPreview(true); renderPreview(true);

View file

@ -26,7 +26,7 @@ export const useNarrativeStore = defineStore('narrative', () => {
title: data.value.title, title: data.value.title,
author: data.value.author, author: data.value.author,
cover: data.value.cover, cover: data.value.cover,
introduction: data.value.introduction introduction: data.value.introduction,
}); });
// Recursively flatten children // Recursively flatten children
@ -41,7 +41,7 @@ export const useNarrativeStore = defineStore('narrative', () => {
subtitle: child.subtitle, subtitle: child.subtitle,
tags: child.tags, tags: child.tags,
cover: child.cover, cover: child.cover,
text: child.text text: child.text,
}); });
// Add geoformat chapters // Add geoformat chapters
@ -53,7 +53,7 @@ export const useNarrativeStore = defineStore('narrative', () => {
id: child.id, id: child.id,
template: 'chapitre', template: 'chapitre',
title: child.title, title: child.title,
blocks: child.blocks blocks: child.blocks,
}); });
} else if (child.template === 'carte') { } else if (child.template === 'carte') {
items.push({ items.push({
@ -61,7 +61,7 @@ export const useNarrativeStore = defineStore('narrative', () => {
template: 'carte', template: 'carte',
title: child.title, title: child.title,
tags: child.tags, tags: child.tags,
text: child.text text: child.text,
}); });
} }
} }
@ -122,6 +122,6 @@ export const useNarrativeStore = defineStore('narrative', () => {
// Actions // Actions
loadNarrative, loadNarrative,
reset reset,
}; };
}); });