Cambios desde el servidor cliente
This commit is contained in:
@@ -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 `<h${level} id="${id}">${text}</h${level}>`;
|
||||
});
|
||||
return DOMPurify.sanitize(htmlWithIds);
|
||||
if (browser) {
|
||||
return DOMPurify.sanitize(htmlWithIds);
|
||||
}
|
||||
return htmlWithIds;
|
||||
}
|
||||
|
||||
function scrollToHeader(id: string) {
|
||||
|
||||
@@ -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, '<h1>$1</h1>')
|
||||
.replace(/^## (.*$)/gim, '<h2>$1</h2>')
|
||||
.replace(/\*\*(.*)\*\*/gim, '<b>$1</b>')
|
||||
.replace(/\n/gim, '<br />');
|
||||
}
|
||||
// @ts-ignore
|
||||
return DOMPurify.sanitize(marked.parse(text || '') as string);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user