refactor: migrate to nuxt compatibilityVersion: 4 (#3298)
This commit is contained in:
parent
46e4433e1c
commit
a3fbc056a9
342 changed files with 1200 additions and 2932 deletions
28
app/composables/settings/metadata.ts
Normal file
28
app/composables/settings/metadata.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import type { Node } from 'ultrahtml'
|
||||
import { decode } from 'tiny-decode'
|
||||
import { parse, TEXT_NODE } from 'ultrahtml'
|
||||
|
||||
export const maxAccountFieldCount = computed(() => isGlitchEdition.value ? 16 : 4)
|
||||
|
||||
export function convertMetadata(metadata: string) {
|
||||
try {
|
||||
const tree = parse(metadata)
|
||||
return (tree.children as Node[]).map(n => convertToText(n)).join('').trim()
|
||||
}
|
||||
catch (err) {
|
||||
console.error(err)
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function convertToText(input: Node): string {
|
||||
let text = ''
|
||||
|
||||
if (input.type === TEXT_NODE)
|
||||
return decode(input.value)
|
||||
|
||||
if ('children' in input)
|
||||
text = (input.children as Node[]).map(n => convertToText(n)).join('')
|
||||
|
||||
return text
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue