From 7c74c2f22ac51a99852621ae0e5901e50c66ce60 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Tue, 6 Feb 2024 19:51:21 +0100 Subject: [PATCH] docs: improve config display --- docs/components/content/ComponentCard.vue | 3 +-- docs/components/content/ComponentExample.vue | 3 +-- docs/components/content/ComponentPreset.vue | 20 +++++++++++++------- docs/composables/useShikiHighlighter.ts | 6 ++++-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/docs/components/content/ComponentCard.vue b/docs/components/content/ComponentCard.vue index dd233129..8ad0236a 100644 --- a/docs/components/content/ComponentCard.vue +++ b/docs/components/content/ComponentCard.vue @@ -122,6 +122,7 @@ const componentProps = reactive({ ...props.props }) const { $prettier } = useNuxtApp() const appConfig = useAppConfig() const route = useRoute() +const highlighter = useShikiHighlighter() let name = props.slug || `U${upperFirst(camelCase(route.params.slug[route.params.slug.length - 1]))}` @@ -267,8 +268,6 @@ function renderObject (obj: any) { return obj } -const highlighter = useShikiHighlighter() - const { data: ast } = await useAsyncData( `${name}-ast-${JSON.stringify({ props: componentProps, slots: props.slots, code: props.code })}`, async () => { diff --git a/docs/components/content/ComponentExample.vue b/docs/components/content/ComponentExample.vue index 647aea92..f276889a 100644 --- a/docs/components/content/ComponentExample.vue +++ b/docs/components/content/ComponentExample.vue @@ -24,7 +24,6 @@ import { fetchContentExampleCode } from '~/composables/useContentExamplesCode' import { transformContent } from '@nuxt/content/transformers' import { useShikiHighlighter } from '~/composables/useShikiHighlighter' - const props = defineProps({ component: { type: String, @@ -77,10 +76,10 @@ if (['command-palette-theme-algolia', 'command-palette-theme-raycast', 'vertical const instance = getCurrentInstance() const camelName = camelCase(component) const data = await fetchContentExampleCode(camelName) +const highlighter = useShikiHighlighter() const hasCode = computed(() => !props.hiddenCode && (data?.code || instance.slots.code)) -const highlighter = useShikiHighlighter() const { data: ast } = await useAsyncData(`content-example-${camelName}-ast`, () => transformContent('content:_markdown.md', `\`\`\`vue\n${data?.code ?? ''}\n\`\`\``, { markdown: { highlight: { diff --git a/docs/components/content/ComponentPreset.vue b/docs/components/content/ComponentPreset.vue index dd472039..9a4038ee 100644 --- a/docs/components/content/ComponentPreset.vue +++ b/docs/components/content/ComponentPreset.vue @@ -5,6 +5,8 @@