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

breaking(v2): editUrl should point to website instead of docsDir #1958

Merged
merged 1 commit into from
Nov 11, 2019
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
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