mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-25 01:10:40 +01:00
docs(app): implement AI search
This commit is contained in:
44
docs/app/components/prose/PreStream.vue
Normal file
44
docs/app/components/prose/PreStream.vue
Normal file
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import { ShikiCachedRenderer } from 'shiki-stream/vue'
|
||||
|
||||
const colorMode = useColorMode()
|
||||
const highlighter = await useHighlighter()
|
||||
const props = defineProps<{
|
||||
code: string
|
||||
language: string
|
||||
class?: string
|
||||
meta?: string
|
||||
}>()
|
||||
const trimmedCode = computed(() => {
|
||||
return props.code.trim().replace(/`+$/, '')
|
||||
})
|
||||
const lang = computed(() => {
|
||||
switch (props.language) {
|
||||
case 'vue':
|
||||
return 'vue'
|
||||
case 'javascript':
|
||||
return 'js'
|
||||
case 'typescript':
|
||||
return 'ts'
|
||||
case 'css':
|
||||
return 'css'
|
||||
default:
|
||||
return props.language
|
||||
}
|
||||
})
|
||||
const key = computed(() => {
|
||||
return `${lang.value}-${colorMode.value}`
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ProsePre v-bind="props">
|
||||
<ShikiCachedRenderer
|
||||
:key="key"
|
||||
:highlighter="highlighter"
|
||||
:code="trimmedCode"
|
||||
:lang="lang"
|
||||
:theme="colorMode.value === 'dark' ? 'material-theme-palenight' : 'material-theme-lighter'"
|
||||
/>
|
||||
</ProsePre>
|
||||
</template>
|
||||
Reference in New Issue
Block a user