From 96e18ef2331f9ba09ead9ecfa20059d80ec52d1d Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Thu, 11 Jul 2024 17:36:50 +0200 Subject: [PATCH] docs(ComponentExample): add --- docs/app/components/content/ComponentCode.vue | 2 +- .../components/content/ComponentExample.vue | 26 +++++++++++++++++ .../app/components/content/ComponentTheme.vue | 2 +- .../content/HighlightInlineType.vue | 2 +- docs/app/composables/fetchComponentExample.ts | 28 ++++++++++++++++++ docs/app/composables/fetchComponentMeta.ts | 2 +- .../composables/fetchContentExamplesCode.ts | 29 ------------------- ...-examples-code.ts => component-example.ts} | 16 +++++----- docs/nuxt.config.ts | 1 - ...s-code.get.ts => component-example.get.ts} | 4 +-- 10 files changed, 68 insertions(+), 44 deletions(-) create mode 100644 docs/app/components/content/ComponentExample.vue create mode 100644 docs/app/composables/fetchComponentExample.ts delete mode 100644 docs/app/composables/fetchContentExamplesCode.ts rename docs/modules/{content-examples-code.ts => component-example.ts} (87%) rename docs/server/api/{content-examples-code.get.ts => component-example.get.ts} (84%) diff --git a/docs/app/components/content/ComponentCode.vue b/docs/app/components/content/ComponentCode.vue index d74853dd..880215be 100644 --- a/docs/app/components/content/ComponentCode.vue +++ b/docs/app/components/content/ComponentCode.vue @@ -101,7 +101,7 @@ const code = computed(() => { return code }) -const { data: ast } = await useAsyncData(`${name}-code-${JSON.stringify({ props: componentProps, slots: props.slots })}`, async () => { +const { data: ast } = await useAsyncData(`component-code-${name}-${JSON.stringify({ props: componentProps, slots: props.slots })}`, async () => { let formatted = '' try { formatted = await $prettier.format(code.value) diff --git a/docs/app/components/content/ComponentExample.vue b/docs/app/components/content/ComponentExample.vue new file mode 100644 index 00000000..e3146355 --- /dev/null +++ b/docs/app/components/content/ComponentExample.vue @@ -0,0 +1,26 @@ + + + diff --git a/docs/app/components/content/ComponentTheme.vue b/docs/app/components/content/ComponentTheme.vue index fe689429..ce05034c 100644 --- a/docs/app/components/content/ComponentTheme.vue +++ b/docs/app/components/content/ComponentTheme.vue @@ -33,7 +33,7 @@ const component = computed(() => { return stripCompoundVariants(component) }) -const { data: ast } = await useAsyncData(`${name}-theme`, () => parseMarkdown(` +const { data: ast } = await useAsyncData(`component-theme-${name}`, () => parseMarkdown(` \`\`\`yml ${json5.stringify(component.value, null, 2).replace(/,([ |\t\n]+[}|\])])/g, '$1')} \`\`\`\ diff --git a/docs/app/components/content/HighlightInlineType.vue b/docs/app/components/content/HighlightInlineType.vue index b63e852f..cff1b634 100644 --- a/docs/app/components/content/HighlightInlineType.vue +++ b/docs/app/components/content/HighlightInlineType.vue @@ -14,7 +14,7 @@ const type = computed(() => { return props.type }) -const { data: ast } = await useAsyncData(`hightlight-inline-code-` + props.type, () => parseMarkdown(`\`${type.value}\`{lang="ts-type"}`)) +const { data: ast } = await useAsyncData(`hightlight-inline-code-${props.type}`, () => parseMarkdown(`\`${type.value}\`{lang="ts-type"}`))