mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-29 19:30:37 +01:00
docs(ComponentTheme): avoid using prettier to improve performances
This commit is contained in:
@@ -4,7 +4,6 @@ import { camelCase } from 'scule'
|
|||||||
import * as theme from '#build/ui'
|
import * as theme from '#build/ui'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { $prettier } = useNuxtApp()
|
|
||||||
|
|
||||||
const name = camelCase(route.params.slug[route.params.slug.length - 1])
|
const name = camelCase(route.params.slug[route.params.slug.length - 1])
|
||||||
|
|
||||||
@@ -37,20 +36,18 @@ function stripCompoundVariants(component) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const component = computed(() => {
|
const component = computed(() => {
|
||||||
const component = { ...theme[name] }
|
return {
|
||||||
|
ui: {
|
||||||
return stripCompoundVariants(component)
|
[name]: stripCompoundVariants(theme[name])
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const { data: ast } = await useAsyncData(`component-theme-${name}`, async () => {
|
const { data: ast } = await useAsyncData(`component-theme-${name}`, async () => {
|
||||||
const md = `
|
const md = `
|
||||||
::code-collapse
|
::code-collapse
|
||||||
\`\`\`ts [app.config.ts]
|
\`\`\`ts [app.config.ts]
|
||||||
export default defineAppConfig({
|
export default defineAppConfig(${json5.stringify(component.value, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')})
|
||||||
ui: {
|
|
||||||
${name}: ${json5.stringify(component.value, null, 2)}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
\`\`\`\
|
\`\`\`\
|
||||||
|
|
||||||
::
|
::
|
||||||
@@ -63,18 +60,7 @@ Some colors in \`compoundVariants\` are omitted for readability. Check out the s
|
|||||||
: ''}
|
: ''}
|
||||||
`
|
`
|
||||||
|
|
||||||
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