mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
feat(v2): allow per-doc hiding of edit url (#2166)
This commit is contained in:
parent
428e087eb7
commit
75f5bb4d23
4 changed files with 42 additions and 1 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
custom_edit_url: null
|
||||||
|
---
|
||||||
|
|
||||||
|
Lorem ipsum.
|
|
@ -84,6 +84,14 @@ Array [
|
||||||
},
|
},
|
||||||
"path": "/docs/hello",
|
"path": "/docs/hello",
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"component": "@theme/DocItem",
|
||||||
|
"exact": true,
|
||||||
|
"modules": Object {
|
||||||
|
"content": "@site/docs/ipsum.md",
|
||||||
|
},
|
||||||
|
"path": "/docs/ipsum",
|
||||||
|
},
|
||||||
Object {
|
Object {
|
||||||
"component": "@theme/DocItem",
|
"component": "@theme/DocItem",
|
||||||
"exact": true,
|
"exact": true,
|
||||||
|
|
|
@ -143,6 +143,34 @@ describe('simple site', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('docs with null custom_edit_url', async () => {
|
||||||
|
const source = 'ipsum.md';
|
||||||
|
const options = {
|
||||||
|
routeBasePath,
|
||||||
|
showLastUpdateAuthor: true,
|
||||||
|
showLastUpdateTime: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const data = await processMetadata({
|
||||||
|
source,
|
||||||
|
refDir: docsDir,
|
||||||
|
context,
|
||||||
|
options,
|
||||||
|
env,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(data).toEqual({
|
||||||
|
id: 'ipsum',
|
||||||
|
permalink: '/docs/ipsum',
|
||||||
|
source: path.join('@site', routeBasePath, source),
|
||||||
|
title: 'ipsum',
|
||||||
|
editUrl: null,
|
||||||
|
description: 'Lorem ipsum.',
|
||||||
|
lastUpdatedAt: 1539502055,
|
||||||
|
lastUpdatedBy: 'Author',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('docs with invalid id', async () => {
|
test('docs with invalid id', async () => {
|
||||||
const badSiteDir = path.join(fixtureDir, 'bad-site');
|
const badSiteDir = path.join(fixtureDir, 'bad-site');
|
||||||
const options = {
|
const options = {
|
||||||
|
|
|
@ -134,7 +134,7 @@ export default async function processMetadata({
|
||||||
description,
|
description,
|
||||||
source: aliasedSitePath(filePath, siteDir),
|
source: aliasedSitePath(filePath, siteDir),
|
||||||
permalink,
|
permalink,
|
||||||
editUrl: custom_edit_url || docsEditUrl,
|
editUrl: custom_edit_url !== undefined ? custom_edit_url : docsEditUrl,
|
||||||
version,
|
version,
|
||||||
lastUpdatedBy,
|
lastUpdatedBy,
|
||||||
lastUpdatedAt,
|
lastUpdatedAt,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue