mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 16:47:26 +02:00
breaking(v2): editUrl should point to website instead of docsDir to support editUrl in versioning/trans (#1958)
This commit is contained in:
parent
1235fc9f7e
commit
6a3efd5f3d
5 changed files with 13 additions and 8 deletions
|
@ -80,7 +80,7 @@ describe('processMetadata', () => {
|
||||||
|
|
||||||
test('docs with editUrl', async () => {
|
test('docs with editUrl', async () => {
|
||||||
const editUrl =
|
const editUrl =
|
||||||
'https://github.com/facebook/docusaurus/edit/master/website/docs/';
|
'https://github.com/facebook/docusaurus/edit/master/website';
|
||||||
const source = path.join('foo', 'baz.md');
|
const source = path.join('foo', 'baz.md');
|
||||||
const data = await processMetadata({
|
const data = await processMetadata({
|
||||||
source,
|
source,
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {parse, normalizeUrl} from '@docusaurus/utils';
|
import {parse, normalizeUrl, posixPath} from '@docusaurus/utils';
|
||||||
import {DocusaurusConfig} from '@docusaurus/types';
|
import {DocusaurusConfig} from '@docusaurus/types';
|
||||||
|
|
||||||
import lastUpdate from './lastUpdate';
|
import lastUpdate from './lastUpdate';
|
||||||
|
@ -100,7 +100,10 @@ export default async function processMetadata({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editUrl) {
|
if (editUrl) {
|
||||||
metadata.editUrl = normalizeUrl([editUrl, source]);
|
metadata.editUrl = normalizeUrl([
|
||||||
|
editUrl,
|
||||||
|
posixPath(path.relative(siteDir, filePath)),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metadata.custom_edit_url) {
|
if (metadata.custom_edit_url) {
|
||||||
|
|
|
@ -131,9 +131,9 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
path: 'docs',
|
path: 'docs',
|
||||||
/**
|
/**
|
||||||
* URL for editing docs, example: 'https://github.com/facebook/docusaurus/edit/master/website/docs/'
|
* URL for editing website repo, example: 'https://github.com/facebook/docusaurus/edit/master/website/'
|
||||||
*/
|
*/
|
||||||
editUrl: 'https://github.com/repo/project/website/docs/',
|
editUrl: 'https://github.com/repo/project/website/',
|
||||||
/**
|
/**
|
||||||
* URL route for the blog section of your site
|
* URL route for the blog section of your site
|
||||||
* do not include trailing slash
|
* do not include trailing slash
|
||||||
|
|
|
@ -274,6 +274,8 @@ Deprecated. Create a `CNAME` file in your `static` folder instead with your cust
|
||||||
|
|
||||||
#### `customDocsPath`, `docsUrl`, `editUrl`, `enableUpdateBy`, `enableUpdateTime`
|
#### `customDocsPath`, `docsUrl`, `editUrl`, `enableUpdateBy`, `enableUpdateTime`
|
||||||
|
|
||||||
|
**BREAKING**: `editUrl` should point to (website) docusaurus project instead of `docs` directory.
|
||||||
|
|
||||||
Deprecated. Pass it as an option to `@docusaurus/preset-classic` docs instead:
|
Deprecated. Pass it as an option to `@docusaurus/preset-classic` docs instead:
|
||||||
|
|
||||||
```jsx {9-22}
|
```jsx {9-22}
|
||||||
|
@ -287,9 +289,9 @@ module.exports = {
|
||||||
docs: {
|
docs: {
|
||||||
// Equivalent to `customDocsPath`.
|
// Equivalent to `customDocsPath`.
|
||||||
path: 'docs',
|
path: 'docs',
|
||||||
// Equivalent to `editUrl`
|
// Equivalent to `editUrl` but should point to `website` dir instead of `website/docs`
|
||||||
editUrl:
|
editUrl:
|
||||||
'https://github.com/facebook/docusaurus/edit/master/website/docs/',
|
'https://github.com/facebook/docusaurus/edit/master/website',
|
||||||
// Equivalent to `docsUrl`.
|
// Equivalent to `docsUrl`.
|
||||||
routeBasePath: 'docs',
|
routeBasePath: 'docs',
|
||||||
// Remark and Rehype plugins passed to MDX. Replaces `markdownOptions` and `markdownPlugins`.
|
// Remark and Rehype plugins passed to MDX. Replaces `markdownOptions` and `markdownPlugins`.
|
||||||
|
|
|
@ -33,7 +33,7 @@ module.exports = {
|
||||||
path: 'docs',
|
path: 'docs',
|
||||||
sidebarPath: require.resolve('./sidebars.js'),
|
sidebarPath: require.resolve('./sidebars.js'),
|
||||||
editUrl:
|
editUrl:
|
||||||
'https://github.com/facebook/docusaurus/edit/master/website/docs/',
|
'https://github.com/facebook/docusaurus/edit/master/website/',
|
||||||
showLastUpdateAuthor: true,
|
showLastUpdateAuthor: true,
|
||||||
showLastUpdateTime: true,
|
showLastUpdateTime: true,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue