Skip to content

Commit 7043ece

Browse files
committed
fix: fix jsdom esmodule requirement err
1 parent 6d25411 commit 7043ece

3 files changed

Lines changed: 117 additions & 337 deletions

File tree

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"framer-motion": "^11.15.0",
2929
"geist": "^1.5.1",
3030
"gray-matter": "^4.0.3",
31-
"jsdom": "^27.2.0",
31+
"sanitize-html": "^2.11.0",
3232
"lucide-react": "^0.456.0",
3333
"marked": "^17.0.0",
3434
"next": "15.5.3",

apps/web/src/app/(main)/dashboard/oss-programs/[slug]/page.tsx

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { getProgramBySlug, getAllPrograms } from "@/data/oss-programs";
22
import { notFound } from "next/navigation";
33
import { marked } from "marked";
4-
import DOMPurify from "dompurify";
5-
import { JSDOM } from "jsdom";
4+
import sanitizeHtml from "sanitize-html";
65
import { ProgramHeader, ProgramMetadata, ProgramSection } from "@/components/oss-programs";
76
import "./program-styles.css";
87

@@ -34,9 +33,46 @@ export default async function ProgramPage({
3433

3534
const renderMarkdown = (markdown: string) => {
3635
const html = marked.parse(markdown) as string;
37-
const window = new JSDOM("").window;
38-
const purify = DOMPurify(window);
39-
return purify.sanitize(html);
36+
return sanitizeHtml(html, {
37+
allowedTags: [
38+
"h1",
39+
"h2",
40+
"h3",
41+
"h4",
42+
"h5",
43+
"h6",
44+
"p",
45+
"br",
46+
"strong",
47+
"em",
48+
"u",
49+
"s",
50+
"code",
51+
"pre",
52+
"ul",
53+
"ol",
54+
"li",
55+
"blockquote",
56+
"a",
57+
"img",
58+
"table",
59+
"thead",
60+
"tbody",
61+
"tr",
62+
"th",
63+
"td",
64+
"hr",
65+
"div",
66+
"span",
67+
],
68+
allowedAttributes: {
69+
a: ["href", "title", "target", "rel"],
70+
img: ["src", "alt", "title", "width", "height"],
71+
code: ["class"],
72+
pre: ["class"],
73+
},
74+
allowedSchemes: ["http", "https", "mailto"],
75+
});
4076
};
4177

4278
return (

0 commit comments

Comments
 (0)