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