2019-01-27 05:34:52 +00:00
|
|
|
<template>
|
2019-08-27 10:44:49 +00:00
|
|
|
<x-prism :inline="inline" :language="prismLang">{{ code }}</x-prism>
|
2019-01-27 05:34:52 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import 'prismjs';
|
2019-01-27 11:03:58 +00:00
|
|
|
import 'prismjs/themes/prism-okaidia.css';
|
2019-08-27 10:44:49 +00:00
|
|
|
import XPrism from 'vue-prism-component';
|
2019-01-27 05:34:52 +00:00
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
2019-08-27 10:44:49 +00:00
|
|
|
XPrism
|
2019-01-27 05:34:52 +00:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
code: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
lang: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
inline: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false
|
|
|
|
}
|
2019-08-27 10:44:49 +00:00
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
prismLang() {
|
|
|
|
return Prism.languages[this.lang] ? this.lang : 'js';
|
|
|
|
}
|
2019-01-27 05:34:52 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|