Fix video embeds to display correctly in articles

Update DOMPurify to allow the 'style' attribute on iframes and adjust CSS to correctly handle vertical video aspect ratios, ensuring proper display of embedded content.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 413891e8-d784-4bea-b9f5-91a5a68316b4
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: 59104823-d3a5-43b2-b639-53c5c8511b1a
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/413891e8-d784-4bea-b9f5-91a5a68316b4/cftwqyT
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
sebastjanartic 2026-02-28 16:50:20 +00:00
parent 8cad711d11
commit 000edc48e5
2 changed files with 3 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 717 KiB

View File

@ -25,7 +25,7 @@ const ALLOWED_IFRAME_DOMAINS = [
function sanitizeContent(html: string): string {
return DOMPurify.sanitize(html, {
ADD_TAGS: ["iframe"],
ADD_ATTR: ["allow", "allowfullscreen", "frameborder", "scrolling", "src", "loading"],
ADD_ATTR: ["allow", "allowfullscreen", "frameborder", "scrolling", "src", "loading", "style"],
ALLOW_UNKNOWN_PROTOCOLS: false,
});
}
@ -178,9 +178,8 @@ export default function ArticlePage() {
prose-a:text-primary prose-a:no-underline hover:prose-a:underline
prose-strong:text-foreground
prose-img:rounded-md prose-img:w-full prose-img:object-cover
[&_iframe]:w-full [&_iframe]:aspect-video [&_iframe]:rounded-md [&_iframe]:my-6
[&_.embed-container]:relative [&_.embed-container]:w-full [&_.embed-container]:my-6
[&_.embed-container_iframe]:absolute [&_.embed-container_iframe]:inset-0 [&_.embed-container_iframe]:w-full [&_.embed-container_iframe]:h-full
[&_iframe]:rounded-md [&_iframe]:my-6 [&_iframe]:max-w-full
[&_div[style]]:flex [&_div[style]]:justify-center
[&_blockquote]:border-l-primary [&_blockquote]:bg-accent/50 [&_blockquote]:rounded-r-md [&_blockquote]:py-1"
dangerouslySetInnerHTML={{ __html: sanitizeContent(article.content) }}
data-testid="article-content"