parent
037837b551
commit
0e4a111f81
1714 changed files with 20803 additions and 11751 deletions
35
packages/client/src/components/code-core.vue
Normal file
35
packages/client/src/components/code-core.vue
Normal file
|
@ -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>
|
Loading…
Add table
Add a link
Reference in a new issue