Currently the PostPreview component only displays the article title, cover image, and authors. Adding an optional Svelte snippet would allow rich preview content for articles.

Problem

Svelte snippets cannot be passed through JSON. The current architecture:

  1. Pages export metadata in <script module>
  2. page-renderer.svelte.js extracts exports into JSON feed
  3. Articles.svelte reads from page.data.feed (JSON)
  4. PostPreview.svelte renders from JSON data

Svelte snippets are runtime constructs that cannot be serialized to JSON.

Solution

Import all page modules directly in the layout and map them to feed items, bypassing JSON serialization for snippet data.

Tasks

  • Import all page modules in layout using import.meta.glob
  • Create a map from feed item URLs to page modules
  • Extract snippet from page module and pass to PostPreview
  • Update PostPreview.svelte to accept and render optional snippet prop

Considerations

  • Performance impact of importing all page modules in layout
  • May want different snippet visibility for compact vs fancy layouts
  • Snippet should be optional - fall back to title-only preview

Better previews

Rich article snippets

A static site template built with SvelteKit.

Sveleton, 2025