Skip to content

Commit

Permalink
docs(ComponentCard): fix inline highlighter (#750)
Browse files Browse the repository at this point in the history
Co-authored-by: Benjamin Canac <[email protected]>
  • Loading branch information
KeJunMao and benjamincanac authored Sep 28, 2023
1 parent 3e647e4 commit 8b7a013
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
13 changes: 2 additions & 11 deletions docs/components/content/ComponentCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</component>
</div>

<ContentRenderer v-if="!previewOnly" :value="ast" class="[&>pre]:!rounded-t-none" />
<ContentRenderer v-if="!previewOnly" :value="ast" class="[&>div>pre]:!rounded-t-none" />
</div>
</template>

Expand Down Expand Up @@ -209,16 +209,7 @@ function renderObject (obj: any) {
}
const shikiHighlighter = useShikiHighlighter({})
const codeHighlighter = async (code: string, lang: string, theme: any, highlights: any) => {
const styleMap = {}
const { tree, className } = await shikiHighlighter.getHighlightedAST(code, lang, theme, { styleMap, highlights })
return {
tree,
className,
style: shikiHighlighter.generateStyles(styleMap),
styleMap
}
}
const codeHighlighter = async (code: string, lang: string, theme: any, highlights: number[]) => shikiHighlighter.getHighlightedAST(code, lang, theme, { highlights })
const { data: ast } = await useAsyncData(`${name}-ast-${JSON.stringify({ props: componentProps, slots: props.slots })}`, () => transformContent('content:_markdown.md', code.value, {
markdown: {
highlight: {
Expand Down
2 changes: 1 addition & 1 deletion docs/components/content/ComponentExample.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="[&>pre]:!rounded-t-none">
<div class="[&>div>pre]:!rounded-t-none">
<div class="flex border border-gray-200 dark:border-gray-700 relative not-prose rounded-t-md" :class="[{ 'p-4': padding, 'rounded-b-md': !$slots.code, 'border-b-0': !!$slots.code }, backgroundClass, overflowClass]">
<ContentSlot v-if="$slots.default" :use="$slots.default" />
</div>
Expand Down

1 comment on commit 8b7a013

@vercel
Copy link

@vercel vercel bot commented on 8b7a013 Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ui – ./

ui-nuxt-js.vercel.app
ui-git-dev-nuxt-js.vercel.app
ui.nuxt.com

Please sign in to comment.