Skip to content

Commit

Permalink
fix: unable to use non-GitHub repo in editLink
Browse files Browse the repository at this point in the history
close vuejs#694
  • Loading branch information
kecrily committed Jun 2, 2022
1 parent 6e53be6 commit ed291fc
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
55 changes: 55 additions & 0 deletions docs/config/theme-configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,61 @@ export interface Footer {
}
```

## editLink

- Type: `EditLink`

Edit link configuration. You can then customize git repo link and display text.

```ts
export default {
themeConfig: {
editLink: {
domain: 'github.com'
repo: 'vuejs/vitepress',
branch: 'next',
dir: 'docs',
text: 'Edit this page on GitHub'
},
}
}
```

```ts
export interface EditLink {
/**
* Domain of git repo
*
* @example 'github.com' or 'https://github.com'
*/
domain?: string
/**
* Repo of the site.
*
* @example 'vuejs/docs'
*/
repo: string
/**
* Branch of the repo.
*
* @default 'main'
*/
branch?: string
/**
* If your docs are not at the root of the repo.
*
* @example 'docs'
*/
dir?: string
/**
* Custom text for edit link.
*
* @default 'Edit this page'
*/
text?: string
}
```

## lastUpdatedText

- Type: `string`
Expand Down
2 changes: 1 addition & 1 deletion src/client/theme-default/composables/edit-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function useEditLink() {

return computed(() => {
const url = [
'https://github.com',
`https://${theme.value.editLink?.domain || 'github.com'}`,
theme.value.editLink?.repo || '???',
'edit',
theme.value.editLink?.branch || 'main',
Expand Down
7 changes: 7 additions & 0 deletions types/default-theme.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ export namespace DefaultTheme {
// edit link -----------------------------------------------------------------

export interface EditLink {
/**
* Domain of git repo
*
* @example 'github.com' or 'https://github.com'
*/
domain?: string

/**
* Repo of the site.
*
Expand Down

0 comments on commit ed291fc

Please sign in to comment.