refactor(content-{blog,docs}): unify handling of tags (#7117)

This commit is contained in:
Joshua Chen 2022-04-07 21:58:21 +08:00 committed by GitHub
parent ca718ccac0
commit 1156be3f20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 170 additions and 178 deletions

View file

@ -7,8 +7,9 @@
declare module '@docusaurus/plugin-content-blog' {
import type {MDXOptions} from '@docusaurus/mdx-loader';
import type {FrontMatterTag, Tag} from '@docusaurus/utils';
import type {FrontMatterTag} from '@docusaurus/utils';
import type {Overwrite} from 'utility-types';
import type {Tag} from '@docusaurus/types';
export type Assets = {
/**
@ -406,17 +407,6 @@ declare module '@docusaurus/plugin-content-blog' {
}
>;
export type TagModule = {
/** Permalink of the tag's own page. */
permalink: string;
/** Name of the tag. */
name: string;
/** Number of posts with this tag. */
count: number;
/** The tags list page. */
allTagsPath: string;
};
export type BlogSidebar = {
title: string;
items: {title: string; permalink: string}[];
@ -511,28 +501,30 @@ declare module '@theme/BlogListPage' {
}
declare module '@theme/BlogTagsListPage' {
import type {BlogSidebar, TagModule} from '@docusaurus/plugin-content-blog';
import type {BlogSidebar} from '@docusaurus/plugin-content-blog';
import type {TagsListItem} from '@docusaurus/types';
export interface Props {
/** Blog sidebar. */
readonly sidebar: BlogSidebar;
/** A map from tag names to the full tag module. */
readonly tags: Readonly<{[tagName: string]: TagModule}>;
/** All tags declared in this blog. */
readonly tags: TagsListItem[];
}
export default function BlogTagsListPage(props: Props): JSX.Element;
}
declare module '@theme/BlogTagsPostsPage' {
import type {BlogSidebar, TagModule} from '@docusaurus/plugin-content-blog';
import type {BlogSidebar} from '@docusaurus/plugin-content-blog';
import type {Content} from '@theme/BlogPostPage';
import type {Metadata} from '@theme/BlogListPage';
import type {TagModule} from '@docusaurus/types';
export interface Props {
/** Blog sidebar. */
readonly sidebar: BlogSidebar;
/** Metadata of this tag. */
readonly metadata: TagModule;
readonly tag: TagModule;
/** Looks exactly the same as the posts list page */
readonly listMetadata: Metadata;
/**