75 lines
1.5 KiB
Vue
75 lines
1.5 KiB
Vue
|
<template>
|
||
|
<div :hidden="!content">
|
||
|
<b-container fluid>
|
||
|
<b-row>
|
||
|
<b-col>
|
||
|
<Viewer :content="content" />
|
||
|
</b-col>
|
||
|
</b-row>
|
||
|
<b-row>
|
||
|
<b-col cols="10">
|
||
|
<label for="tagList" >Tags</label>
|
||
|
</b-col>
|
||
|
</b-row>
|
||
|
<b-row>
|
||
|
<b-col cols="10">
|
||
|
<TagList id="tagList" :tags="tags" :readOnly="true" />
|
||
|
</b-col>
|
||
|
</b-row>
|
||
|
</b-container>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import Viewer from "./Viewer";
|
||
|
import TagList from "./TagList";
|
||
|
export default {
|
||
|
name: "MainView",
|
||
|
props: {
|
||
|
slug: String
|
||
|
},
|
||
|
created() {
|
||
|
if (this.$props.slug) {
|
||
|
this.getFile(this.$props.slug)
|
||
|
}
|
||
|
},
|
||
|
data: function () {
|
||
|
return {
|
||
|
file: ''
|
||
|
}
|
||
|
},
|
||
|
computed: {
|
||
|
tags: function() {
|
||
|
if (this.file) {
|
||
|
return this.file.tags
|
||
|
}
|
||
|
return []
|
||
|
},
|
||
|
content: function () {
|
||
|
if (this.file) {
|
||
|
return this.file.contents
|
||
|
}
|
||
|
return null
|
||
|
}
|
||
|
},
|
||
|
watch: {
|
||
|
slug: function (newValue) {
|
||
|
this.getFile(newValue)
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
getFile: function(slug) {
|
||
|
this.$store.dispatch('getFile', slug)
|
||
|
.then(file => {
|
||
|
this.file = file
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
components: {TagList, Viewer}
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style scoped>
|
||
|
|
||
|
</style>
|