fix: render code block without language (#276)
This commit is contained in:
parent
18d5fd4804
commit
0f06653636
4 changed files with 32 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
|||
<script setup lang="ts">
|
||||
const props = defineProps<{
|
||||
code: string
|
||||
lang: string
|
||||
lang?: string
|
||||
}>()
|
||||
|
||||
const raw = $computed(() => decodeURIComponent(props.code).replace(/'/g, '\''))
|
||||
|
@ -13,7 +13,7 @@ const langMap: Record<string, string> = {
|
|||
}
|
||||
|
||||
const highlighted = computed(() => {
|
||||
return props.lang ? highlightCode(raw, langMap[props.lang] || props.lang as any) : raw
|
||||
return props.lang ? highlightCode(raw, (langMap[props.lang] || props.lang) as any) : raw
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue