diff --git a/frontend/src/routes/dashboard/help-center/[uuid]/+page.svelte b/frontend/src/routes/dashboard/help-center/[uuid]/+page.svelte
index 07f6a6e6..66a799b4 100644
--- a/frontend/src/routes/dashboard/help-center/[uuid]/+page.svelte
+++ b/frontend/src/routes/dashboard/help-center/[uuid]/+page.svelte
@@ -48,6 +48,8 @@
});
}
+ import { browser } from '$app/environment';
+
function renderMarkdown(content: string) {
const rawHtml = marked.parse(content || '') as string;
// Add IDs to headers for TOC navigation
@@ -55,7 +57,10 @@
const id = text.toLowerCase().replace(/[^\w]+/g, '-');
return `${text}`;
});
- return DOMPurify.sanitize(htmlWithIds);
+ if (browser) {
+ return DOMPurify.sanitize(htmlWithIds);
+ }
+ return htmlWithIds;
}
function scrollToHeader(id: string) {
diff --git a/frontend/src/routes/dashboard/help-center/editor/[uuid]/+page.svelte b/frontend/src/routes/dashboard/help-center/editor/[uuid]/+page.svelte
index 7eeec691..a098954a 100644
--- a/frontend/src/routes/dashboard/help-center/editor/[uuid]/+page.svelte
+++ b/frontend/src/routes/dashboard/help-center/editor/[uuid]/+page.svelte
@@ -139,15 +139,9 @@
}
}
+ import { browser } from '$app/environment';
+
function renderMarkdown(text: string) {
- if (!browser) {
- // Basic fallback for SSR to avoid crashing
- return (text || '')
- .replace(/^# (.*$)/gim, '
$1
')
- .replace(/^## (.*$)/gim, '$1
')
- .replace(/\*\*(.*)\*\*/gim, '$1')
- .replace(/\n/gim, '
');
- }
// @ts-ignore
return DOMPurify.sanitize(marked.parse(text || '') as string);
}