Timothy Gerla 688efabb93 fix: clean up docs page scripts in preparation for 0.5 docs
- simplify the docs page handling logic and get more nuxt-like
- the handleClick function was vestigial and didn't do anything anymore, remove it
- simplify the Vuex state quite a bit, remove activeDocPath
- clean up github link generation code, and fix #2076

Signed-off-by: Timothy Gerla <tim@gerla.net>
2020-05-02 02:49:19 -07:00

52 lines
1.3 KiB
Vue

<template>
<article class="max-w-3xl pt-1 pb-4 pl-6 pr-6 mx-auto c-rich-text">
<div class="flex">
<h2 class="page-heading flex-grow">{{ doc.title }}</h2>
<a :href="gitPath" class="no-underline font-normal text-sm self-center"
><img
src="/images/Git-Icon-Black.png"
height="14px"
width="14px"
class="inline-block mr-1"
alt=""
/>
Edit this page
</a>
</div>
<div v-html="doc.content" class="border-t pt-4"></div>
</article>
</template>
<script>
export default {
name: 'Content',
computed: {
doc() {
const sections = this.$store.state.sidebar.sections
let activeDocPath = ''
// if there's an #anchor specified, go there
if (this.$route.hash) {
activeDocPath = this.$route.hash.substring(1)
} else {
// otherwise go to the first item in the menu
activeDocPath = this.$store.state.sidebar.menu[0].path
}
return sections[activeDocPath]
},
gitPath() {
let path =
'https://github.com/talos-systems/talos/edit/master/docs/website/content/'
if (this.$route.hash) {
path += this.$route.hash.substring(1)
} else {
path += this.$store.state.sidebar.menu[0].path + '/index'
}
return path + '.md'
}
}
}
</script>