forked from Mirrors/elk
c9ae7cf942
closes #102, partial #40
23 lines
489 B
Vue
23 lines
489 B
Vue
<script setup lang="ts">
|
|
const props = defineProps<{
|
|
code: string
|
|
lang: string
|
|
}>()
|
|
|
|
const raw = $computed(() => decodeURIComponent(props.code).replace(/'/g, '\''))
|
|
|
|
const langMap: Record<string, string> = {
|
|
js: 'javascript',
|
|
ts: 'typescript',
|
|
vue: 'html',
|
|
}
|
|
|
|
const hightlighted = computed(() => {
|
|
return props.lang ? highlightCode(raw, langMap[props.lang] || props.lang as any) : raw
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<pre class="code-block" v-html="hightlighted" />
|
|
</template>
|