1
0
Fork 0
mirror of https://github.com/mat-1/matdoesdev.git synced 2025-08-02 06:36:04 +00:00

remove empty comments from blog post json

This commit is contained in:
mat 2025-01-01 12:52:19 +00:00
parent dd419eee02
commit 812fd9ac0f

View file

@ -95,7 +95,9 @@ export async function getPost(slug: string): Promise<BlogPost | null> {
// console.log('renderHtml', renderHtml)
// HACK: sveltekit adds garbage around the content, we just want what's in the article tag
const html = /<article.*?>([\w\W]+)(?:<!---->)<\/article>/.exec(renderHtml.body)?.[1] ?? ''
let html = /<article.*?>([\w\W]+)(?:<!---->)<\/article>/.exec(renderHtml.body)?.[1] ?? ''
// sveltekit also adds random empty comments like "<!---->", we don't want those
html = html.replace(/<!---->/g, '')
const css = Array.from(result.css)
.map((css) => css.code)