Skip to content

Commit

Permalink
breaking(v2): editUrl should point to website instead of docsDir to s…
Browse files Browse the repository at this point in the history
…upport editUrl in versioning/trans (#1958)
  • Loading branch information
endiliey authored Nov 11, 2019
1 parent 1235fc9 commit 6a3efd5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('processMetadata', () => {

test('docs with editUrl', async () => {
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 data = await processMetadata({
source,
Expand Down
7 changes: 5 additions & 2 deletions packages/docusaurus-plugin-content-docs/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import fs from 'fs-extra';
import path from 'path';
import {parse, normalizeUrl} from '@docusaurus/utils';
import {parse, normalizeUrl, posixPath} from '@docusaurus/utils';
import {DocusaurusConfig} from '@docusaurus/types';

import lastUpdate from './lastUpdate';
Expand Down Expand Up @@ -100,7 +100,10 @@ export default async function processMetadata({
}

if (editUrl) {
metadata.editUrl = normalizeUrl([editUrl, source]);
metadata.editUrl = normalizeUrl([
editUrl,
posixPath(path.relative(siteDir, filePath)),
]);
}

if (metadata.custom_edit_url) {
Expand Down
4 changes: 2 additions & 2 deletions website/docs/advanced-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ module.exports = {
*/
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
* do not include trailing slash
Expand Down
6 changes: 4 additions & 2 deletions website/docs/migrating-from-v1-to-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ Deprecated. Create a `CNAME` file in your `static` folder instead with your cust

#### `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:

```jsx {9-22}
Expand All @@ -287,9 +289,9 @@ module.exports = {
docs: {
// Equivalent to `customDocsPath`.
path: 'docs',
// Equivalent to `editUrl`
// Equivalent to `editUrl` but should point to `website` dir instead of `website/docs`
editUrl:
'https://github.com/facebook/docusaurus/edit/master/website/docs/',
'https://github.com/facebook/docusaurus/edit/master/website',
// Equivalent to `docsUrl`.
routeBasePath: 'docs',
// Remark and Rehype plugins passed to MDX. Replaces `markdownOptions` and `markdownPlugins`.
Expand Down
2 changes: 1 addition & 1 deletion website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {
path: 'docs',
sidebarPath: require.resolve('./sidebars.js'),
editUrl:
'https://github.com/facebook/docusaurus/edit/master/website/docs/',
'https://github.com/facebook/docusaurus/edit/master/website/',
showLastUpdateAuthor: true,
showLastUpdateTime: true,
},
Expand Down

0 comments on commit 6a3efd5

Please sign in to comment.