fix: SSR render error on profile page

This commit is contained in:
三咲智子 2023-01-04 17:26:31 +08:00
parent a8135197c9
commit 8983edd1bb
No known key found for this signature in database
GPG key ID: 69992F2250DFD93E

View file

@ -5,8 +5,11 @@ import { TEXT_NODE, parse, render, walkSync } from 'ultrahtml'
import { findAndReplaceEmojisInText } from '@iconify/utils'
import { emojiRegEx, getEmojiAttributes } from '../config/emojis'
const decoder = process.client ? document.createElement('textarea') : null as any as HTMLTextAreaElement
const decoder = process.client ? document.createElement('textarea') : null
export function decodeHtml(text: string) {
if (!decoder)
// not available when SSR
return text
decoder.innerHTML = text
return decoder.value
}