mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-14 01:27:35 +02:00
feat: support reference-style linking in documents (#1048)
feat: support reference-style linking in documents
This commit is contained in:
parent
7488de266f
commit
bbf355fdc7
7 changed files with 180 additions and 14 deletions
|
@ -55,9 +55,15 @@ const doc3 = fs.readFileSync(
|
|||
'utf8',
|
||||
);
|
||||
|
||||
const refLinks = fs.readFileSync(
|
||||
path.join(__dirname, '__fixtures__', 'reflinks.md'),
|
||||
'utf8',
|
||||
);
|
||||
|
||||
const rawContent1 = metadataUtils.extractMetadata(doc1).rawContent;
|
||||
const rawContent2 = metadataUtils.extractMetadata(doc2).rawContent;
|
||||
const rawContent3 = metadataUtils.extractMetadata(doc3).rawContent;
|
||||
const rawContentRefLinks = metadataUtils.extractMetadata(refLinks).rawContent;
|
||||
|
||||
describe('mdToHtmlify', () => {
|
||||
const mdToHtml = metadataUtils.mdToHtml(Metadata, '/');
|
||||
|
@ -105,6 +111,17 @@ describe('mdToHtmlify', () => {
|
|||
expect(content3).toMatchSnapshot();
|
||||
expect(content3).not.toEqual(rawContent3);
|
||||
});
|
||||
|
||||
test('transforms reference links', () => {
|
||||
const contentRefLinks = docs.mdToHtmlify(
|
||||
rawContentRefLinks,
|
||||
mdToHtml,
|
||||
Metadata['en-reflinks'],
|
||||
);
|
||||
expect(contentRefLinks).toContain('/docs/en/next/');
|
||||
expect(contentRefLinks).toMatchSnapshot();
|
||||
expect(contentRefLinks).not.toEqual(rawContentRefLinks);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFile', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue