Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow edit URL to be customized with doc metadata #443

Merged
merged 3 commits into from
Feb 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/api-doc-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ original_id: doc1
---
```

`custom_edit_url`: The url for editing this document. If this field is not present, the document's edit url will fallback to `editUrl` from optional fields of `siteConfig.js`. See [siteConfig.js](site-config.md) docs for more information.

For example:

```markdown
---
id: doc-markdown
title: Markdown Features
custom_edit_url: https://github.com/facebook/Docusaurus/edit/master/docs/api-doc-markdown.md
---
```

### Blog Posts

Blog Posts use the following markdown header fields that are enclosed by a line `---` on either side:
Expand Down
10 changes: 5 additions & 5 deletions lib/core/Doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class Doc extends React.Component {
docSource = docSource.match(new RegExp(/version-.*\/(.*\.md)/, 'i'))[1];
}

let editLink = this.props.config.editUrl && (
<a
className="edit-page-link button"
href={this.props.config.editUrl + docSource}
target="_blank">
const editUrl =
this.props.metadata.custom_edit_url ||
(this.props.config.editUrl && this.props.config.editUrl + docSource);
let editLink = editUrl && (
<a className="edit-page-link button" href={editUrl} target="_blank">
{editThisDoc}
</a>
);
Expand Down