mirror of https://github.com/vuejs/vitepress
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
445 B
19 lines
445 B
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: string
|
|
if (typeof pattern === 'function') {
|
|
url = pattern(page.value)
|
|
} else {
|
|
url = pattern.replace(/:path/g, page.value.filePath)
|
|
}
|
|
|
|
return { url, text }
|
|
})
|
|
}
|