fix: ssr issues

This commit is contained in:
Xyphyn committed 2023-10-10 17:15:08 -07:00
1 parent e3c7aca8ee
commit 16154bbc23
9 files changed
+146 -146

No files matched your search

+10 -4
View File
@@ -1,10 +1,12 @@
<script lang="ts">
import { md, mdInline, photonify } from '$lib/components/markdown/markdown'
import { userSettings } from '$lib/settings.js'
import { onMount } from 'svelte'
export let source: string = ''
export let inline: boolean = false
let rendered = ''
function replaceURLs(node: HTMLElement, source: string) {
if (!div) return
const links = node.querySelectorAll('a')
@@ -17,18 +19,22 @@
let div: HTMLElement
const render = (source: string): string => {
function render(source: string): string {
if (!source || source == '') return ''
try {
return inline ? mdInline.render(source) : md.render(source)
const output = inline ? mdInline.render(source) : md.render(source)
return output
} catch (err) {
console.error(err)
return ''
}
}
$: rendered = render(source)
$: replaceURLs(div, rendered)
onMount(() => {
rendered = `${rendered} `
})
</script>
<div