docs(HighlightInlintType): hide undefined in types

This commit is contained in:
Benjamin Canac
2024-09-10 11:25:40 +02:00
parent 3d0e1eb288
commit a2a303f527

View File

@@ -4,17 +4,24 @@ const props = defineProps<{
}>()
const type = computed(() => {
if (props.type.includes(', "as" | "asChild" | "forceMount">')) {
return props.type.replace(`, "as" | "asChild" | "forceMount">`, ``).replace('Omit<', '')
let type = props.type
if (type.includes(', "as" | "asChild" | "forceMount">')) {
type = type.replace(`, "as" | "asChild" | "forceMount">`, ``).replace('Omit<', '')
}
if (props.type.includes(', "as" | "asChild">')) {
return props.type.replace(', "as" | "asChild">', '').replace('Omit<', '')
if (type.includes(', "as" | "asChild">')) {
type = type.replace(', "as" | "asChild">', '').replace('Omit<', '')
}
if (type.startsWith('undefined |')) {
type = type.replace('undefined |', '')
}
if (type.endsWith('| undefined')) {
type = type.replace('| undefined', '')
}
return props.type
return 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-${type.value}`, () => parseMarkdown(`\`${type.value}\`{lang="ts-type"}`))
</script>
<template>