mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-09 14:22:27 +02:00
Allow edit URL to be customized with doc metadata (#443)
This commit is contained in:
parent
5e39b2e01f
commit
41750667cd
2 changed files with 17 additions and 5 deletions
|
@ -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
|
||||||
|
|
||||||
Blog Posts use the following markdown header fields that are enclosed by a line `---` on either side:
|
Blog Posts use the following markdown header fields that are enclosed by a line `---` on either side:
|
||||||
|
|
|
@ -27,11 +27,11 @@ class Doc extends React.Component {
|
||||||
docSource = docSource.match(new RegExp(/version-.*\/(.*\.md)/, 'i'))[1];
|
docSource = docSource.match(new RegExp(/version-.*\/(.*\.md)/, 'i'))[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
let editLink = this.props.config.editUrl && (
|
const editUrl =
|
||||||
<a
|
this.props.metadata.custom_edit_url ||
|
||||||
className="edit-page-link button"
|
(this.props.config.editUrl && this.props.config.editUrl + docSource);
|
||||||
href={this.props.config.editUrl + docSource}
|
let editLink = editUrl && (
|
||||||
target="_blank">
|
<a className="edit-page-link button" href={editUrl} target="_blank">
|
||||||
{editThisDoc}
|
{editThisDoc}
|
||||||
</a>
|
</a>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue