docs: make generate work

This commit is contained in:
Benjamin Canac
2024-09-24 17:53:21 +02:00
parent d921b764de
commit b7f9422091
10 changed files with 41 additions and 28 deletions

View File

@@ -2,6 +2,7 @@
<script setup lang="ts">
import json5 from 'json5'
import { upperFirst, camelCase, kebabCase } from 'scule'
import { hash } from 'ohash'
import * as theme from '#build/ui'
import { get, set } from '#ui/utils'
@@ -179,7 +180,7 @@ const code = computed(() => {
return code
})
const { data: ast } = await useAsyncData(`component-code-${name}-${JSON.stringify({ props: componentProps, slots: props.slots })}`, async () => {
const { data: ast } = await useAsyncData(`component-code-${name}-${hash({ props: componentProps, slots: props.slots })}`, async () => {
if (!props.prettier) {
return parseMarkdown(code.value)
}

View File

@@ -22,7 +22,7 @@ const meta = await fetchComponentMeta(name as any)
</ProseTr>
</ProseThead>
<ProseTbody>
<ProseTr v-for="event in meta.meta.events" :key="event.name">
<ProseTr v-for="event in (meta?.meta?.events || [])" :key="event.name">
<ProseTd>
<ProseCodeInline>
{{ event.name }}

View File

@@ -22,7 +22,7 @@ const meta = await fetchComponentMeta(name as any)
</ProseTr>
</ProseThead>
<ProseTbody>
<ProseTr v-for="slot in meta.meta.slots" :key="slot.name">
<ProseTr v-for="slot in (meta?.meta?.slots || [])" :key="slot.name">
<ProseTd>
<ProseCodeInline>
{{ slot.name }}

View File

@@ -9,8 +9,8 @@ const name = camelCase(route.params.slug?.[route.params.slug.length - 1] ?? '')
const strippedCompoundVariants = ref(false)
function stripCompoundVariants(component: any) {
if (component.compoundVariants) {
function stripCompoundVariants(component?: any) {
if (component?.compoundVariants) {
component.compoundVariants = component.compoundVariants.filter((compoundVariant: any) => {
if (compoundVariant.color) {
if (!['primary', 'gray'].includes(compoundVariant.color)) {

View File

@@ -1,4 +1,6 @@
<script setup lang="ts">
import { murmurHash } from 'ohash'
const props = defineProps<{
type: string
}>()
@@ -21,7 +23,7 @@ const type = computed(() => {
return type
})
const { data: ast } = await useAsyncData(`hightlight-inline-code-${type.value}`, () => parseMarkdown(`\`${type.value}\`{lang="ts-type"}`))
const { data: ast } = await useAsyncData(`hightlight-inline-code-${murmurHash(type.value)}`, () => parseMarkdown(`\`${type.value}\`{lang="ts-type"}`))
</script>
<template>