diff --git a/web/src/routes/[username]/[workspace]/[collection]/[slug]/+page.svelte b/web/src/routes/[username]/[workspace]/[collection]/[slug]/+page.svelte index eef33db4..fff6eabe 100644 --- a/web/src/routes/[username]/[workspace]/[collection]/[slug]/+page.svelte +++ b/web/src/routes/[username]/[workspace]/[collection]/[slug]/+page.svelte @@ -24,6 +24,7 @@ import { authStore } from '$lib/stores/auth.svelte'; import { starredStore } from '$lib/stores/starred.svelte'; import { titleStore } from '$lib/stores/title.svelte'; + import { workspaceStore } from '$lib/stores/workspace.svelte'; type RelationshipEntry = { key: string; @@ -118,8 +119,30 @@ // Sync coordinator — refresh item data on tab resume let unsubscribeSync: (() => void) | null = null; + let unsubscribeBeforePrint: (() => void) | null = null; + + // Print header/footer state (PLAN-620 / TASK-623). Initialized on mount + // and refreshed on `beforeprint` so the printed page reflects the + // actual moment of print, not whenever the page last loaded. + let printDate = $state(''); + let printUrl = $state(''); + + function refreshPrintMeta() { + if (typeof window === 'undefined') return; + printDate = new Date().toLocaleDateString(undefined, { + year: 'numeric', + month: 'long', + day: 'numeric' + }); + printUrl = window.location.href; + } onMount(() => { + refreshPrintMeta(); + const handler = () => refreshPrintMeta(); + window.addEventListener('beforeprint', handler); + unsubscribeBeforePrint = () => window.removeEventListener('beforeprint', handler); + unsubscribeSync = syncService.onSync(async (result) => { if (!wsSlug || !itemSlug || !item) return; // Don't refresh if the user is actively editing @@ -163,6 +186,7 @@ onDestroy(() => { unsubscribeSync?.(); + unsubscribeBeforePrint?.(); editorStore.resetForDoc(); collectionStore.setActiveItem(null); }); @@ -621,6 +645,22 @@ {:else if error}
{error}
{:else if item && collection} + + + +