mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-15 18:17:35 +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
|
@ -10,13 +10,17 @@ import {
|
|||
SidebarItemDoc,
|
||||
SidebarItemLink,
|
||||
SidebarItem,
|
||||
VersionTag,
|
||||
DocMetadata,
|
||||
} from './types';
|
||||
import {
|
||||
import type {
|
||||
PropSidebars,
|
||||
PropVersionMetadata,
|
||||
PropSidebarItem,
|
||||
PropTagDocList,
|
||||
PropTagDocListDoc,
|
||||
} from '@docusaurus/plugin-content-docs-types';
|
||||
import {keyBy, mapValues} from 'lodash';
|
||||
import {compact, keyBy, mapValues} from 'lodash';
|
||||
|
||||
export function toSidebarsProp(loadedVersion: LoadedVersion): PropSidebars {
|
||||
const docsById = keyBy(loadedVersion.docs, (doc) => doc.id);
|
||||
|
@ -79,3 +83,34 @@ export function toVersionMetadataProp(
|
|||
docsSidebars: toSidebarsProp(loadedVersion),
|
||||
};
|
||||
}
|
||||
|
||||
export function toTagDocListProp({
|
||||
allTagsPath,
|
||||
tag,
|
||||
docs,
|
||||
}: {
|
||||
allTagsPath: string;
|
||||
tag: VersionTag;
|
||||
docs: Pick<DocMetadata, 'id' | 'title' | 'description' | 'permalink'>[];
|
||||
}): PropTagDocList {
|
||||
function toDocListProp(): PropTagDocListDoc[] {
|
||||
const list = compact(
|
||||
tag.docIds.map((id) => docs.find((doc) => doc.id === id)),
|
||||
);
|
||||
// Sort docs by title
|
||||
list.sort((doc1, doc2) => doc1.title.localeCompare(doc2.title));
|
||||
return list.map((doc) => ({
|
||||
id: doc.id,
|
||||
title: doc.title,
|
||||
description: doc.description,
|
||||
permalink: doc.permalink,
|
||||
}));
|
||||
}
|
||||
|
||||
return {
|
||||
name: tag.name,
|
||||
permalink: tag.permalink,
|
||||
docs: toDocListProp(),
|
||||
allTagsPath,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue