2022-05-03 14:52:04 +02:00
|
|
|
<template>
|
2022-05-11 14:48:04 +02:00
|
|
|
<div class="box ma7 p-5">
|
|
|
|
<h2
|
|
|
|
v-if="page"
|
|
|
|
v-html="page.name"
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
v-if="page"
|
|
|
|
v-html="page.content"
|
|
|
|
/>
|
2022-05-03 14:52:04 +02:00
|
|
|
|
2022-05-11 14:48:04 +02:00
|
|
|
<router-link
|
|
|
|
:to="editTarget"
|
|
|
|
variant="outline"
|
|
|
|
>
|
|
|
|
<button>
|
|
|
|
<i class="fa fa-2x fa-fw fa-edit"/>
|
|
|
|
</button>
|
|
|
|
</router-link>
|
|
|
|
<hr>
|
|
|
|
</div>
|
2022-05-03 14:52:04 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-05-11 14:48:04 +02:00
|
|
|
import axios from 'axios'
|
2022-05-13 17:58:13 +02:00
|
|
|
//import h from 'highlightjs'
|
|
|
|
//import hi from 'highlightjs-line-numbers.js'
|
|
|
|
|
|
|
|
//hi.highlightAll()
|
|
|
|
//hi.initLineNumbersOnLoad()
|
2022-05-03 14:52:04 +02:00
|
|
|
|
|
|
|
export default {
|
2022-05-11 14:48:04 +02:00
|
|
|
name: 'PagesDisplay',
|
|
|
|
props: {
|
|
|
|
slug: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data: () => ({
|
|
|
|
page: null
|
|
|
|
}),
|
|
|
|
computed: {
|
|
|
|
editTarget() {
|
|
|
|
if (this.page) {
|
|
|
|
return `/pages/edit/${this.page.slug}`
|
|
|
|
}
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
beforeMount() {
|
|
|
|
this.getPagesDetails()
|
|
|
|
this.$watch(
|
|
|
|
() => this.slug,
|
|
|
|
() => {
|
|
|
|
this.getPagesDetails()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async getPagesDetails() {
|
|
|
|
await axios.get(`/api/pages?slug=${this.slug}`)
|
|
|
|
.then((response) => {
|
|
|
|
[this.page] = response.data['hydra:member']
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2022-05-03 14:52:04 +02:00
|
|
|
}
|
2022-05-11 14:48:04 +02:00
|
|
|
</script>
|