mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-22 02:15:11 +01:00
4940894324
fixes #8944
20 lines
666 B
Vue
20 lines
666 B
Vue
<!-- eslint-disable vue/no-v-html -->
|
|
<template>
|
|
<code v-if="inline" :class="`language-${prismLang}`" v-html="html"></code>
|
|
<pre v-else :class="`language-${prismLang}`"><code :class="`language-${prismLang}`" v-html="html"></code></pre>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed } from 'vue';
|
|
import Prism from 'prismjs';
|
|
import 'prismjs/themes/prism-okaidia.css';
|
|
|
|
const props = defineProps<{
|
|
code: string;
|
|
lang?: string;
|
|
inline?: boolean;
|
|
}>();
|
|
|
|
const prismLang = computed(() => Prism.languages[props.lang] ? props.lang : 'js');
|
|
const html = computed(() => Prism.highlight(props.code, Prism.languages[prismLang.value], prismLang.value));
|
|
</script>
|