-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathEditPage.vue
29 lines (22 loc) · 971 Bytes
/
EditPage.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<template>
<c-h-stack align-items="center" mt="6">
<c-icon name="info" />
<c-link :href="editUrl ? editUrl : `https://github.com/chakra-ui/vue-docs`" is-external
:_hover="{ color: '#55c392', textDecoration: 'underline' }">
Edit this page on GitHub
</c-link>
</c-h-stack>
</template>
<script setup lang="ts">
import { CHStack, CIcon, CLink } from '@chakra-ui/vue-next';
import { documentationUrl } from '~/config/site-config';
import { useRoute, useRouter } from 'vue-router';
const route = computed(() => useRoute());
const path = computed(() => route.value.path);
console.log(path.value);
const { data, refresh } = await useAsyncData(`content-${path}`, () => {
return queryContent().where({ _path: path.value }).findOne()
}, { watch: [route] })
const routeSlug = data.value?._id.toString().replace(/:/g, "/").replace(/\s/g, "");
const editUrl = ref<string>(`${documentationUrl}/${routeSlug}`);
</script>