forked from FoundKeyGang/FoundKey
[MFM] Fallback to js if specified lang is not available (#5347)
This commit is contained in:
parent
13f69e4291
commit
9d65768d4d
1 changed files with 9 additions and 3 deletions
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue