[MFM] Fallback to js if specified lang is not available (#5347)

This commit is contained in:
Aya Morisawa 2019-08-27 19:44:49 +09:00 committed by syuilo
parent 13f69e4291
commit 9d65768d4d
1 changed files with 9 additions and 3 deletions

View File

@ -1,16 +1,16 @@
<template>
<prism :inline="inline" :language="lang || 'js'">{{ code }}</prism>
<x-prism :inline="inline" :language="prismLang">{{ code }}</x-prism>
</template>
<script lang="ts">
import Vue from 'vue';
import 'prismjs';
import 'prismjs/themes/prism-okaidia.css';
import Prism from 'vue-prism-component';
import XPrism from 'vue-prism-component';
export default Vue.extend({
components: {
Prism
XPrism
},
props: {
code: {
@ -25,6 +25,12 @@ export default Vue.extend({
type: Boolean,
required: false
}
},
computed: {
prismLang() {
return Prism.languages[this.lang] ? this.lang : 'js';
}
}
});
</script>