Skip to content

Commit

Permalink
fix!
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Apr 6, 2022
1 parent ba181a0 commit 5d09121
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-content-blog/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ export default async function pluginContentBlog(
label: tag.label,
permalink: tag.permalink,
allTagsPath: blogTagsListPath,
count: tag.items.length,
};
const tagPropPath = await createData(
`${docuHash(metadata.permalink)}.json`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ exports[`simple website content: data 1`] = `
\\"label\\": \\"tag 1\\",
\\"permalink\\": \\"/docs/tags/tag-1\\",
\\"allTagsPath\\": \\"/docs/tags\\",
\\"count\\": 2,
\\"items\\": [
{
\\"id\\": \\"foo/baz\\",
Expand All @@ -736,6 +737,7 @@ exports[`simple website content: data 1`] = `
\\"label\\": \\"tag 2\\",
\\"permalink\\": \\"/docs/tags/tag2-custom-permalink\\",
\\"allTagsPath\\": \\"/docs/tags\\",
\\"count\\": 1,
\\"items\\": [
{
\\"id\\": \\"foo/baz\\",
Expand All @@ -749,6 +751,7 @@ exports[`simple website content: data 1`] = `
\\"label\\": \\"tag 3\\",
\\"permalink\\": \\"/docs/tags/tag-3\\",
\\"allTagsPath\\": \\"/docs/tags\\",
\\"count\\": 1,
\\"items\\": [
{
\\"id\\": \\"hello\\",
Expand Down Expand Up @@ -3175,6 +3178,7 @@ exports[`versioned website content: data 1`] = `
\\"label\\": \\"barTag 1\\",
\\"permalink\\": \\"/docs/next/tags/bar-tag-1\\",
\\"allTagsPath\\": \\"/docs/next/tags\\",
\\"count\\": 1,
\\"items\\": [
{
\\"id\\": \\"foo/bar\\",
Expand All @@ -3188,6 +3192,7 @@ exports[`versioned website content: data 1`] = `
\\"label\\": \\"barTag-2\\",
\\"permalink\\": \\"/docs/next/tags/bar-tag-2\\",
\\"allTagsPath\\": \\"/docs/next/tags\\",
\\"count\\": 1,
\\"items\\": [
{
\\"id\\": \\"foo/bar\\",
Expand All @@ -3201,6 +3206,7 @@ exports[`versioned website content: data 1`] = `
\\"label\\": \\"barTag 3\\",
\\"permalink\\": \\"/docs/next/tags/barTag-3-permalink\\",
\\"allTagsPath\\": \\"/docs/next/tags\\",
\\"count\\": 1,
\\"items\\": [
{
\\"id\\": \\"foo/bar\\",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('toTagDocListProp', () => {

expect(result).toEqual({
allTagsPath,
count: 2,
label: tag.label,
permalink: tag.permalink,
items: [doc3, doc1], // docs sorted by title, ignore "id5" absence
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-content-docs/src/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export function toTagDocListProp({
label: tag.label,
permalink: tag.permalink,
allTagsPath,
count: tag.docIds.length,
items: toDocListProp(),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ export default function BlogTagsPostsPage({
sidebar,
listMetadata,
}: Props): JSX.Element {
const {allTagsPath, label: tagName} = tag;
const blogPostsPlural = useBlogPostsPlural();
const title = translate(
{
id: 'theme.blog.tagTitle',
description: 'The title of the page for a blog tag',
message: '{nPosts} tagged with "{tagName}"',
},
{nPosts: blogPostsPlural(items.length), tagName},
{nPosts: blogPostsPlural(tag.count), tagName: tag.label},
);

return (
Expand All @@ -69,7 +68,7 @@ export default function BlogTagsPostsPage({
<header className="margin-bottom--xl">
<h1>{title}</h1>

<Link href={allTagsPath}>
<Link href={tag.allTagsPath}>
<Translate
id="theme.tags.tagsPageLink"
description="The label of the link targeting the tag list page">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function DocTagDocListPage({tag}: Props): JSX.Element {
description: 'The title of the page for a docs tag',
message: '{nDocsTagged} with "{tagName}"',
},
{nDocsTagged: nDocsTaggedPlural(tag.items.length), tagName: tag.label},
{nDocsTagged: nDocsTaggedPlural(tag.count), tagName: tag.label},
);

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-types/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ export type TagsListItem = Tag & {
};

/** What the tag's own page should know about the tag. */
export type TagModule = Tag & {
export type TagModule = TagsListItem & {
/** The tags list page's permalink. */
allTagsPath: string;
};

0 comments on commit 5d09121

Please sign in to comment.