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