dm: 컨텐츠1
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import type { ContentsDetail } from "@/src/entities/content/model/contents-interface";
|
||||
|
||||
type ContentsPageClientProps = {
|
||||
@@ -8,28 +7,14 @@ type ContentsPageClientProps = {
|
||||
};
|
||||
|
||||
function ContentsPageClient({ initialContent }: ContentsPageClientProps) {
|
||||
const shadowRootRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!shadowRootRef.current || !initialContent?.contsCn) return;
|
||||
|
||||
const shadowRoot =
|
||||
shadowRootRef.current.shadowRoot ??
|
||||
shadowRootRef.current.attachShadow({ mode: "open" });
|
||||
shadowRoot.innerHTML = "";
|
||||
|
||||
const styleElement = document.createElement("style");
|
||||
styleElement.textContent = `div { font-size: 16px; line-height: 1.5; }`;
|
||||
shadowRoot.appendChild(styleElement);
|
||||
|
||||
const contentElement = document.createElement("div");
|
||||
contentElement.innerHTML = initialContent.contsCn;
|
||||
shadowRoot.appendChild(contentElement);
|
||||
}, [initialContent]);
|
||||
|
||||
return (
|
||||
<div className="card card-border !mt-6 !p-6">
|
||||
<div ref={shadowRootRef} />
|
||||
<div
|
||||
className="contents-page text-[16px] leading-[1.5]"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: initialContent?.contsCn ?? "",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user