monkeeShark/packages/client/src/components/code-core.vue
Kainoa Kanter 1eb504a640
chore: fix client lint errors (#8934)
* Fix client lint

* Hide no-v-html

* Ignore banned type

* Update page-editor.vue
2022-07-05 11:21:59 +09:00

20 lines
670 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>