Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(blog): authors count incorrectly rendered #10431

Merged
merged 5 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default function BlogAuthor({
<AuthorName name={name} as={as} />
</MaybeLink>
)}
{count && <AuthorBlogPostCount count={count} />}
{count !== undefined && <AuthorBlogPostCount count={count} />}
slorber marked this conversation as resolved.
Show resolved Hide resolved
</div>
{!!title && <AuthorTitle title={title} />}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
useBlogAuthorPageTitle,
BlogAuthorsListViewAllLabel,
BlogAuthorNoPostsLabel,
} from '@docusaurus/theme-common/internal';
import Link from '@docusaurus/Link';
import {useBlogMetadata} from '@docusaurus/plugin-content-blog/client';
Expand Down Expand Up @@ -52,9 +53,17 @@ function Content({author, items, sidebar, listMetadata}: Props): JSX.Element {
{author.description && <p>{author.description}</p>}
<ViewAllAuthorsLink />
</header>
<hr />
<BlogPostItems items={items} />
<BlogListPaginator metadata={listMetadata} />
{items.length === 0 ? (
<p>
<BlogAuthorNoPostsLabel />
</p>
) : (
<>
<hr />
<BlogPostItems items={items} />
<BlogListPaginator metadata={listMetadata} />
</>
)}
</BlogLayout>
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-theme-common/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,5 @@ export {
useBlogAuthorPageTitle,
translateBlogAuthorsListPageTitle,
BlogAuthorsListViewAllLabel,
BlogAuthorNoPostsLabel,
} from './translations/blogTranslations';
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,13 @@ export function BlogAuthorsListViewAllLabel(): ReactNode {
</Translate>
);
}

export function BlogAuthorNoPostsLabel(): ReactNode {
return (
<Translate
id="theme.blog.author.noPosts"
description="The text for authors with 0 blog post">
This author has not written any posts yet.
</Translate>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"theme.blog.archive.description___DESCRIPTION": "The page & hero description of the blog archive page",
"theme.blog.archive.title": "Archive",
"theme.blog.archive.title___DESCRIPTION": "The page & hero title of the blog archive page",
"theme.blog.author.noPosts": "This author has not written any posts yet.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect you didn't run the command the CI / tests tells you to run, this is not the expected result from running it.

What did you run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn jest, what am I supposed to run ?

Copy link
Collaborator

@slorber slorber Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are now passing, but you didn't read the message that the previously failing tests printed:

https://github.com/facebook/docusaurus/actions/runs/10473792292/job/29006473892?pr=10431

Errors thrown in packages/docusaurus-theme-translations/locales/tests/locales.test.ts
Summary of all failing tests
FAIL packages/docusaurus-theme-translations/locales/tests/locales.test.ts
● theme translations › has base messages files contain EXACTLY all the translations extracted from the theme. Please run "yarn workspace @docusaurus/theme-translations update" to keep base messages files up-to-date

I can see this because your extracted message has no description, and it only modified the base locale, not all the other localized files.

You are not supposed to enter that message manually in theme translations: it's the CLI command that it supposed to do so

I added the missing translations here:
d7f0fe6

We add the message everywhere so that translators just have to see what is untranslated in their local file, without having to compare it to the English file

"theme.blog.author.pageTitle": "{authorName} - {nPosts}",
"theme.blog.author.pageTitle___DESCRIPTION": "The title of the page for a blog author",
"theme.blog.authorsList.pageTitle": "Authors",
Expand Down