doc.yeswiki.pro/node_modules/vitepress/dist/client/theme-default/composables/edit-link.js

17 lines
493 B
JavaScript
Raw Normal View History

2023-05-20 16:37:42 +00:00
import { computed } from 'vue';
import { useData } from './data';
export function useEditLink() {
const { theme, page } = useData();
return computed(() => {
const { text = 'Edit this page', pattern = '' } = theme.value.editLink || {};
let url;
if (typeof pattern === 'function') {
url = pattern(page.value);
}
else {
url = pattern.replace(/:path/g, page.value.filePath);
}
return { url, text };
});
}