The admin preview never received items/slots/events, so Shop and Upcoming calendar blocks were empty there. loadShopData() (shared) now feeds both the public layout and a new /preview loader. A Shop block with nothing to show (no active items, a filter matching none, or commerce data unavailable because POCKETBASE_ADMIN_* is unset) now says so instead of rendering an empty section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KgF3Kf47LjPGHKQHszpUAv
36 lines
1.1 KiB
Svelte
36 lines
1.1 KiB
Svelte
<script lang="ts">
|
|
import { onMount } from 'svelte';
|
|
import BlockRenderer from '$shared/blocks/BlockRenderer.svelte';
|
|
import type { ContentBlock } from '$lib/types';
|
|
import { rootStyleTag, siteThemeVars } from '$shared/theme';
|
|
|
|
let { data } = $props();
|
|
let blocks = $state<ContentBlock[]>([]);
|
|
let error = $state('');
|
|
|
|
onMount(() => {
|
|
const raw = sessionStorage.getItem('cms-preview-blocks');
|
|
if (!raw) return;
|
|
try {
|
|
const parsed = JSON.parse(raw);
|
|
if (Array.isArray(parsed)) blocks = parsed;
|
|
} catch {
|
|
error = 'The preview data could not be read. Close the preview and open it again.';
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<svelte:head>
|
|
<title>Preview</title>
|
|
<!-- Full site colours so the draft looks like the public site. -->
|
|
{@html rootStyleTag(siteThemeVars(data.colors))}
|
|
</svelte:head>
|
|
|
|
{#if blocks.length}
|
|
<BlockRenderer {blocks} items={data.items} slots={data.slots} calendarEvents={data.calendarEvents} />
|
|
{:else}
|
|
<section class="mx-auto max-w-3xl px-6 py-20 text-center">
|
|
<h1 class="text-4xl">No preview content</h1>
|
|
<p class="mt-4 text-charcoal/65">{error || 'Open preview from the page editor to view the current draft.'}</p>
|
|
</section>
|
|
{/if}
|