mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-09 23:27:28 +02:00
feat(v2): add 'custom_edit_url' and 'hide_title' markdown header feature (#1838)
* feat(v2): add 'custom_edit_url' and 'hide_title' markdown header feature * nits
This commit is contained in:
parent
1dddb1f5ea
commit
94b0451fa4
7 changed files with 62 additions and 4 deletions
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
id: lorem
|
||||
custom_edit_url: https://github.com/customUrl/docs/lorem.md
|
||||
---
|
||||
|
||||
Lorem ipsum.
|
|
@ -101,4 +101,25 @@ describe('processMetadata', () => {
|
|||
description: '## Images',
|
||||
});
|
||||
});
|
||||
|
||||
test('docs with custom editUrl', async () => {
|
||||
const source = 'lorem.md';
|
||||
const data = await processMetadata({
|
||||
source,
|
||||
docsDir,
|
||||
order: {},
|
||||
siteConfig,
|
||||
docsBasePath: pluginPath,
|
||||
siteDir,
|
||||
});
|
||||
|
||||
expect(data).toEqual({
|
||||
id: 'lorem',
|
||||
permalink: '/docs/lorem',
|
||||
source: path.join('@site', pluginPath, source),
|
||||
title: 'lorem',
|
||||
editUrl: 'https://github.com/customUrl/docs/lorem.md',
|
||||
description: 'Lorem ipsum.',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -103,6 +103,11 @@ export default async function processMetadata({
|
|||
metadata.editUrl = normalizeUrl([editUrl, source]);
|
||||
}
|
||||
|
||||
if (metadata.custom_edit_url) {
|
||||
metadata.editUrl = metadata.custom_edit_url;
|
||||
delete metadata.custom_edit_url;
|
||||
}
|
||||
|
||||
if (showLastUpdateAuthor || showLastUpdateTime) {
|
||||
// Use fake data in dev for faster development
|
||||
const fileLastUpdateData =
|
||||
|
|
|
@ -94,6 +94,7 @@ export interface MetadataRaw extends OrderMetadata {
|
|||
editUrl?: string;
|
||||
lastUpdatedAt?: number;
|
||||
lastUpdatedBy?: string;
|
||||
hide_title?: boolean;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue