summaryrefslogtreecommitdiff
path: root/src/client/components/code-core.vue
blob: cfb9d47ed9cba617969af4c24fcbda6dd3719458 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<template>
<XPrism :inline="inline" :language="prismLang">{{ code }}</XPrism>
</template>

<script lang="ts">
import { defineComponent } from 'vue';
import 'prismjs';
import 'prismjs/themes/prism-okaidia.css';
import XPrism from 'vue-prism-component';import * as os from '@/os';

export default defineComponent({
	components: {
		XPrism
	},
	props: {
		code: {
			type: String,
			required: true
		},
		lang: {
			type: String,
			required: false
		},
		inline: {
			type: Boolean,
			required: false
		}
	},
	computed: {
		prismLang() {
			return Prism.languages[this.lang] ? this.lang : 'js';
		}
	}
});
</script>