mirror of
https://github.com/elk-zone/elk.git
synced 2024-12-15 07:31:46 +03:00
22 lines
487 B
Vue
22 lines
487 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 highlighted = computed(() => {
|
|
return props.lang ? highlightCode(raw, langMap[props.lang] || props.lang as any) : raw
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<pre class="code-block" v-html="highlighted" />
|
|
</template>
|