fix(blog): preserve sanitized content through hydration
Deploy Canina / deploy (push) Successful in 2m12s

This commit is contained in:
devops committed 2026-10-17 11:45:34 +00:00
1 parent 5573bb3568
commit 297aaadbe6
6 files changed
+72 -17

No files matched your search

@@ -1,6 +1,5 @@
"use client";
import React, { useState, useEffect } from "react";
import DOMPurify from 'dompurify';
import {
ChevronRight,
Calendar,
@@ -24,9 +23,10 @@ interface BlogPostClientProps {
blog: any;
publishedDate: string;
authorName: string;
sanitizedContent: string;
}
export default function BlogPostClient({ blog, publishedDate, authorName }: BlogPostClientProps) {
export default function BlogPostClient({ blog, publishedDate, authorName, sanitizedContent }: BlogPostClientProps) {
const [copied, setCopied] = useState(false);
const [viewCount, setViewCount] = useState<number>(blog.viewCount || 0);
const [commentName, setCommentName] = useState("");
@@ -176,14 +176,7 @@ export default function BlogPostClient({ blog, publishedDate, authorName }: Blog
{/* Main Rich Content HTML Renderer */}
<div
className="prose prose-base sm:prose-lg max-w-none text-medical-gray-700 leading-loose space-y-5 article-html-content"
dangerouslySetInnerHTML={{
__html: typeof window !== 'undefined'
? DOMPurify.sanitize(blog.content || '', {
ADD_TAGS: ['iframe'],
ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'],
})
: blog.content || '',
}}
dangerouslySetInnerHTML={{ __html: sanitizedContent }}
/>
{/* Tags Chip Footer */}