mirror of
https://github.com/elk-zone/elk
synced 2024-11-28 06:48:14 +09:00
23 lines
475 B
Vue
23 lines
475 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 highlightCode(raw.value, langMap[props.lang] || props.lang as any)
|
||
|
})
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<pre class="code-block" v-html="hightlighted" />
|
||
|
</template>
|