-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
feat(blog): authors page #10216
base: main
Are you sure you want to change the base?
feat(blog): authors page #10216
Conversation
⚡️ Lighthouse report for the deploy preview of this PR
|
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
Size Change: +14 kB (+0.76%) Total Size: 1.86 MB
ℹ️ View Unchanged
|
Not sure about this poc refactor
The filter of the page author is now done in getPageAuthor instead of normalizeAuthor So now we normalize all authors, and for the pageAuthor, we get only the authors with a generatePage === true Is it better like this or the way before ? 🤷 |
This reverts commit 5c789b3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review pass
packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts
Outdated
Show resolved
Hide resolved
} | ||
|
||
export default function AuthorsListByLetter({authors}: Props): JSX.Element { | ||
const letterList = listAuthorsByLetters(authors); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should group authors by letters. We should probably ask the community but it's also possible to list authors as a simple alphabetical line.
Similar to:
https://react.dev/community/team
To me it's unlikely authors will grow as fast as tags. But both options are valid, we can keep it this way for now.
Also: how do we handle authors that have no name? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should group authors by letters.
It would look like this:
To me it's unlikely authors will grow as fast as tags.
In an historical site like mine, it is highly likely that each new contribution will come from a new author.
how do we handle authors that have no name
Good question, it gave me quite some headaches; in the end I added a new object, NamedAuthors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ilg-ul we can't take your site as an example for this feature because we are building a blog plugin, not a chronological site. We enable you to render the list the way you want with swizzling, but it doesn't mean it's what we should provide by default for people that are actually building blogs.
However I'm fine with the current UI, it's not awesome but good enough to ship:
https://deploy-preview-10216--docusaurus-2.netlify.app/blog/authors
Important to note that we only list authors on this page coming from authors.yml
. Inline authors won't appear there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The look is not relevant; the functionality seems equivalent (even better), so no problems so far.
Also no problems to ignore inline authors.
}; | ||
|
||
function getAuthorLetter(author: string): string { | ||
return author[0]!.toUpperCase(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about authors without a name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now authors without names are named internaly with their key
const name = author.name || key; |
So the route and the list of authors by letters are done with the key
function useBlogPostsPlural() { | ||
const {selectMessage} = usePluralForm(); | ||
return (count: number) => | ||
selectMessage( | ||
count, | ||
translate( | ||
{ | ||
id: 'theme.blog.post.plurals', | ||
description: | ||
'Pluralized label for "{count} posts". Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)', | ||
message: 'One post|{count} posts', | ||
}, | ||
{count}, | ||
), | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated, need to be factorized. Since it's not related to styling, it can be moved to theme-common (same for all translation methods btw)
packages/docusaurus-theme-classic/src/theme/BlogPostItem/Header/Author/index.tsx
Outdated
Show resolved
Hide resolved
title: Joi.string(), | ||
email: Joi.string(), | ||
page: Joi.alternatives(Joi.bool(), AuthorPageSchema), | ||
permalink: Joi.string(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We allow bool or AuthorPageSchema, however the type definition of page is null or AuthorPageSchema, tests throws page should be boolean or AuthorPage, else TS yells page to be null
Pre-flight checklist
Motivation
#10196
Todo
Test Plan
Dogfood, unit tests, E2E
- enable argos at the end
Test links
Authors: https://deploy-preview-10216--docusaurus-2.netlify.app/blog/authors
Slorber author: https://deploy-preview-10216--docusaurus-2.netlify.app/blog/authors/slorber
Related issues/PRs
Fix #10196