mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-25 15:07:17 +02:00
feat: doc tags (same as blog tags) (#3646)
* [v2] tags to doc, same as tags to blog - [IN PROGRESS] - Addition of plugin-content-docs - Addition of DocTagsListPage in `docusaurus-theme-classic` ! Error exists for this commit towards the theme aspect and help required. Commit towards #3434 * docs: make tags list page work * temp: disable onBrokenLinks * theme bootstrap: create DocTagsListPage * DocTagsPage added and functionality too - individual doc tag page added to show docs for that specific tag * Added all Docs Tags Link * add some shared tag utils * move tag tests to _dogfooding * fix type * fix some tests * fix blog test * refactor blog post tags handling * better yaml tag examples * better dogfood md files * refactor and factorize theme tag components * finish DocTagDocListPage * Extract DocItemFooter + add inline tag list * minor fix * better typings * fix versions.test.ts tests * add tests for doc tags * fix tests * test toTagDocListProp * move shared theme code to tagUtils * Add new theme translation keys * move common theme code to tagUtils + add tests * update-code-translations should handle theme-common * update french translation * revert add translation * fix pluralization problem in theme.docs.tagDocListPageTitle * add theme component configuration options * add more tags tests * add documentation for docs tagging Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
f666de7e59
commit
f9c79cbd58
81 changed files with 1874 additions and 381 deletions
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {toTagDocListProp} from '../props';
|
||||
|
||||
describe('toTagDocListProp', () => {
|
||||
type Params = Parameters<typeof toTagDocListProp>[0];
|
||||
type Tag = Params['tag'];
|
||||
type Doc = Params['docs'][number];
|
||||
|
||||
const allTagsPath = '/all/tags';
|
||||
|
||||
test('should work', () => {
|
||||
const tag: Tag = {
|
||||
name: 'tag1',
|
||||
permalink: '/tag1',
|
||||
docIds: ['id1', 'id3'],
|
||||
};
|
||||
|
||||
const doc1: Doc = {
|
||||
id: 'id1',
|
||||
title: 'ZZZ 1',
|
||||
description: 'Description 1',
|
||||
permalink: '/doc1',
|
||||
};
|
||||
const doc2: Doc = {
|
||||
id: 'id2',
|
||||
title: 'XXX 2',
|
||||
description: 'Description 2',
|
||||
permalink: '/doc2',
|
||||
};
|
||||
const doc3: Doc = {
|
||||
id: 'id3',
|
||||
title: 'AAA 3',
|
||||
description: 'Description 3',
|
||||
permalink: '/doc3',
|
||||
};
|
||||
const doc4: Doc = {
|
||||
id: 'id4',
|
||||
title: 'UUU 4',
|
||||
description: 'Description 4',
|
||||
permalink: '/doc4',
|
||||
};
|
||||
|
||||
const result = toTagDocListProp({
|
||||
allTagsPath,
|
||||
tag,
|
||||
docs: [doc1, doc2, doc3, doc4],
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
allTagsPath,
|
||||
name: tag.name,
|
||||
permalink: tag.permalink,
|
||||
docs: [doc3, doc1], // docs sorted by title, ignore "id5" absence
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue