Dynamic edit links

This commit is contained in:
Kristian Polso 2018-04-20 16:35:27 +03:00
parent 19afe8a664
commit 9580dd0b25
2 changed files with 19 additions and 8 deletions

View file

@ -7,19 +7,30 @@
<script>
export default {
props: ['path'],
data () {
return {
githubUrl: ''
}
},
name: 'EditLink',
created () {
this.githubUrl = 'https://github.com/'+ this.$site.themeConfig.repo + '/edit/' + this.$site.themeConfig.docsBranch;
methods: {
updateUrl () {
this.githubUrl = 'https://github.com/'+ this.$site.themeConfig.repo + '/edit/' + this.$site.themeConfig.docsBranch;
if(this.$page.path == '/') {
this.githubUrl = this.githubUrl + '/README.md';
} else {
this.githubUrl = this.githubUrl + this.$page.path.replace('.html', '.md');
if(this.$page.path == '/') {
this.githubUrl = this.githubUrl + '/README.md';
} else {
this.githubUrl = this.githubUrl + this.$page.path.replace('.html', '.md');
}
}
},
created () {
this.updateUrl();
},
watch: {
path () {
this.updateUrl();
}
}
}

View file

@ -35,7 +35,7 @@
<Content custom></Content>
<edit-link></edit-link>
<edit-link :path="this.$page.path"></edit-link>
</v-flex>
@ -57,7 +57,7 @@
<Content custom></Content>
<edit-link></edit-link>
<edit-link :path="this.$page.path"></edit-link>
</v-flex>