add basic tab

This commit is contained in:
Philipp Kühn
2020-03-31 19:26:34 +02:00
parent 19adfe3a6c
commit 94349015ec
5 changed files with 49 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<template>
<pre v-if="formattedCode"><code>{{ formattedCode }}</code></pre>
</template>
<script>
import { outdent } from '@mvasilkov/outdent'
export default {
data() {
return {
formattedCode: null
}
},
methods: {
updateCode() {
const text = this.$slots.default[0].text
if (text) {
this.formattedCode = outdent(text)
}
}
},
beforeUpdate() {
this.updateCode()
},
mounted() {
this.updateCode()
},
}
</script>

View File

@@ -2,10 +2,12 @@ import Prism from 'prismjs'
import 'prismjs/themes/prism-coy.css'
import DefaultLayout from '~/layouts/Default.vue'
import Demo from '~/components/Demo'
import Tab from '~/components/Tab'
export default function (Vue, { router, head, isClient }) {
Vue.component('Layout', DefaultLayout)
Vue.component('Demo', Demo)
Vue.component('Tab', Tab)
Vue.filter('highlight', (code, lang = 'javascript') => {
return Prism.highlight(code, Prism.languages[lang], lang)
})