style(body): add neutral figure, wide breakout, details, table header, and quote footer defaults

This commit is contained in:
Jakub Zych
2026-11-28 14:52:41 +01:00
parent 14558e4677
commit be2b332e7c
2 changed files with 72 additions and 1 deletions

View File

@@ -101,7 +101,7 @@ export default defineNuxtPlugin(() => {
- **Order:** sanitize first, expand/hydrate last. `JournalPostBody` and `JournalCategoryHeader` call `expandEmbeds(renderJournalBody(...))` / `expandEmbeds(sanitizeJournalHtml(...))` and wire `useJournalEmbedHydration`. The payload transforms (`toPostView`, `CategoryPage.vue`) only sanitize, so the SSR payload carries the clean `<figure>` markup.
- **SSR static fallback & CLS reservation:** For client-hydrated providers (`component` or `mount`, without `renderSsr`), `expandEmbeds` preserves the SSR fallback `<img>` + `<figcaption>` intact, adds `journal-embed journal-embed--<provider>`, and applies validated `aspect-ratio` / `min-height` inline styles. Before swapping in the hydrated widget on the client, `hydrateEmbedFigure` measures the fallback box height and sets `min-height` to prevent cumulative layout shift (CLS).
- **Lazy hydration, `prefers-reduced-motion`, and resilience:** `useJournalEmbedHydration` observes each validated `<figure data-embed>` with `IntersectionObserver` (default `rootMargin: '200px'`), passes a reactive `reducedMotion` ref synced with `window.matchMedia('(prefers-reduced-motion: reduce)')`, mounts Vue async components via `createVNode` + `render` inheriting `nuxtApp.vueApp._context` (so i18n, router, and Pinia work inside hydrated embeds) or invokes `mount(el, ctx)`, and cleans up on unmount or HTML updates. If dynamic import or mount throws, the error is caught and the SSR static fallback DOM remains intact.
- **Styles:** `.journal-embed--youtube` and iframe embeds default to a `16 / 9` full-width frame; custom embeds render their fallback image, `<figcaption>`, and `.journal-embed__stage` naturally, adding `.journal-embed--hydrated` once mounted.
- **Styles:** `.journal-embed--youtube` and iframe embeds default to a `16 / 9` full-width frame; custom embeds render their fallback image, `<figcaption>`, and `.journal-embed__stage` naturally, adding `.journal-embed--hydrated` once mounted. Inside `.journal-post-body`, `<figure>` / `<figcaption>`, `<details>` / `<summary>`, table `<th>` / `<caption>`, and `<blockquote><footer>` receive neutral `--journal-*` defaults, and `figure.journal-wide` breaks out up to `--journal-wide-width` on wide viewports.
- **Content-Security-Policy:** The hydration runtime is strictly `script-src 'self'` compliant (no `eval`, no `new Function`, no inline `<script>`). Sites using the built-in YouTube iframe still need `frame-src https://www.youtube-nocookie.com`.
## Usage