mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-24 08:50:34 +01:00
docs(IconsTheme): format without prettier to improve performances
This commit is contained in:
@@ -2,31 +2,23 @@
|
|||||||
import json5 from 'json5'
|
import json5 from 'json5'
|
||||||
|
|
||||||
const appConfig = useAppConfig()
|
const appConfig = useAppConfig()
|
||||||
const { $prettier } = useNuxtApp()
|
|
||||||
|
const icons = computed(() => {
|
||||||
|
return {
|
||||||
|
ui: {
|
||||||
|
icons: appConfig.ui.icons
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const { data: ast } = await useAsyncData(`icons-theme`, async () => {
|
const { data: ast } = await useAsyncData(`icons-theme`, async () => {
|
||||||
const md = `
|
const md = `
|
||||||
\`\`\`ts [app.config.ts]
|
\`\`\`ts [app.config.ts]
|
||||||
export default defineAppConfig({
|
export default defineAppConfig(${json5.stringify(icons.value, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')})
|
||||||
ui: {
|
|
||||||
icons: ${json5.stringify(appConfig.ui.icons, null, 2)}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
\`\`\`\
|
\`\`\`\
|
||||||
`
|
`
|
||||||
|
|
||||||
let formatted = ''
|
return parseMarkdown(md)
|
||||||
try {
|
|
||||||
formatted = await $prettier.format(md, {
|
|
||||||
trailingComma: 'none',
|
|
||||||
semi: false,
|
|
||||||
singleQuote: true
|
|
||||||
})
|
|
||||||
} catch {
|
|
||||||
formatted = md
|
|
||||||
}
|
|
||||||
|
|
||||||
return parseMarkdown(formatted)
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user