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