From 14558e467773c60300bfe0d5fa405d4699acf0d5 Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Sat, 28 Nov 2026 13:13:09 +0100 Subject: [PATCH] fix(embeds): address Phase 38 review findings in hydration runtime, plugin sync, and docs --- README.md | 2 +- app/composables/useJournalEmbedHydration.ts | 43 +++++++++++++++++---- app/plugins/journal-embeds.ts | 8 +++- tests/embedHydration.test.ts | 3 ++ 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9ad391b..6a39545 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Route paths are configuration, not files. The layer's page components live in `a - **Post cards**: one link per card, the title; the whole card is clickable through a CSS stretched link, with the focus ring on the card. - **Body links and images**: the CMS's phrase auto-links, the outbound link rules (nofollow or sponsored from the domain lists; new tab, `noopener` and a visually hidden hint while the CMS's links_new_tab is on) and lazy, async body images, applied at SSR on the sanitized body. - **Breadcrumbs and pagination**: `` at the top of every journal page (`journal.breadcrumbs`), and `JournalPagination` as `` with the journal's class names. -- **HTML sanitizer**: post bodies and category content go through `sanitizeJournalHtml` before `v-html` and before they reach the SSR payload. It is [sanitize-html](https://github.com/apostrophecms/sanitize-html) with the Journal API's own allow-list: the usual content elements, `footer`, `class`, schema.org microdata, the `color`, `font-size`, `font-weight` and `text-align` inline styles, and `http`, `https`, `mailto` or relative URLs. Five rules keep the Journal Blog Editor's own markup, mirroring the API's policy: `data-embed` (`youtube`) and `data-id` (an 11-character video id) on `figure`, `alt` with any text on `img` (`alt=""` of a decorative image included), an integer `start` on `ol`, and a `rel` of only `nofollow`, `sponsored` and `ugc` on `a`. `target` is never kept; the outbound link rules add it. With `{ demoteH1: true }`, `h1` headings come out as `h2`. Anything else (`script`, `style`, `iframe`, `svg`, forms, event-handler attributes, `javascript:` URLs in any spelling) is removed and the rest of the value is kept, so a post never renders blank because of one stray tag. Server and browser produce the same string, so hydration matches. See `docs/decisions/0001-sanitize-html.md`. +- **HTML sanitizer**: post bodies and category content go through `sanitizeJournalHtml` before `v-html` and before they reach the SSR payload. It is [sanitize-html](https://github.com/apostrophecms/sanitize-html) with the Journal API's own allow-list: the usual content elements, `footer`, `class`, schema.org microdata, the `color`, `font-size`, `font-weight` and `text-align` inline styles, and `http`, `https`, `mailto` or relative URLs. Rules keep the Journal Blog Editor's own markup, mirroring the API's policy: pair-aware `data-embed` and `data-id` on `figure` against the active embed provider registry (`youtube` by default, plus app-registered providers) alongside validated `data-aspect` and `data-height` CLS hints, `alt` with any text on `img` (`alt=""` of a decorative image included), an integer `start` on `ol`, and a `rel` of only `nofollow`, `sponsored` and `ugc` on `a`. `target` is never kept; the outbound link rules add it. With `{ demoteH1: true }`, `h1` headings come out as `h2`. Anything else (`script`, `style`, `iframe`, `svg`, forms, event-handler attributes, `javascript:` URLs in any spelling) is removed and the rest of the value is kept, so a post never renders blank because of one stray tag. Server and browser produce the same string, so hydration matches. See `docs/decisions/0001-sanitize-html.md`. - **Embeds**: built-in YouTube privacy-enhanced iframes plus an app-extensible embed provider registry (`app.config.ts` and Nuxt plugin helpers) with SSR static fallback preservation, CLS height reservation, `IntersectionObserver` lazy hydration, and `prefers-reduced-motion` support (see [Embeds](#embeds)). - **i18n**: English and Polish UI strings, registered only for the locales the app enables. diff --git a/app/composables/useJournalEmbedHydration.ts b/app/composables/useJournalEmbedHydration.ts index 4bf8937..5ccf9a6 100644 --- a/app/composables/useJournalEmbedHydration.ts +++ b/app/composables/useJournalEmbedHydration.ts @@ -11,6 +11,7 @@ // inline `