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 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 previewFrame2 = 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 selectedElement = ref(null); // Selected element (when popup is open)
const EDGE_THRESHOLD = 30; // px from edge to trigger hover
const PAGE_HIGHLIGHT_COLOR = '#ff8a50';
const ELEMENT_HIGHLIGHT_COLOR = '#7136ff';
let savedScrollPercentage = 0;
const currentFrameIndex = ref(1); // 1 or 2, which iframe is currently visible
@ -559,9 +555,7 @@ const printPreview = async () => {
onMounted(async () => {
// Load narrative data if URL is provided (print mode)
if (narrativeUrl) {
await narrativeStore.loadNarrative(narrativeUrl);
}
await narrativeStore.loadNarrative(location.href + '.json');
// Render preview after data is loaded
renderPreview(true);

View file

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