From 0e4a111f81cceed275d9bec2695f6e401fb654d8 Mon Sep 17 00:00:00 2001
From: syuilo <Syuilotan@yahoo.co.jp>
Date: Fri, 12 Nov 2021 02:02:25 +0900
Subject: refactoring

Resolve #7779
---
 packages/client/src/components/code-core.vue | 35 ++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 packages/client/src/components/code-core.vue

(limited to 'packages/client/src/components/code-core.vue')

diff --git a/packages/client/src/components/code-core.vue b/packages/client/src/components/code-core.vue
new file mode 100644
index 0000000000..9cff7b4448
--- /dev/null
+++ b/packages/client/src/components/code-core.vue
@@ -0,0 +1,35 @@
+<template>
+<code v-if="inline" v-html="html" :class="`language-${prismLang}`"></code>
+<pre v-else :class="`language-${prismLang}`"><code v-html="html" :class="`language-${prismLang}`"></code></pre>
+</template>
+
+<script lang="ts">
+import { defineComponent } from 'vue';
+import 'prismjs';
+import 'prismjs/themes/prism-okaidia.css';
+
+export default defineComponent({
+	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';
+		},
+		html() {
+			return Prism.highlight(this.code, Prism.languages[this.prismLang], this.prismLang);
+		}
+	}
+});
+</script>
-- 
cgit v1.2.3-freya

