-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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): normalize inline authors socials #10424
Conversation
✅ [V2]
To edit notification comments on pull requests, go to your Netlify site configuration. |
⚡️ Lighthouse report for the deploy preview of this PR
|
Size Change: -58.3 kB (-0.5%) Total Size: 11.5 MB
ℹ️ View Unchanged
|
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.
Need to move implementation to normalizeAuthor
+ add a few new tests for getBlogPostAuthors
packages/docusaurus-plugin-content-blog/src/__tests__/authors.test.ts
Outdated
Show resolved
Hide resolved
return authorInput; | ||
return { | ||
...authorInput, | ||
socials: normalizeSocials(authorInput.socials ?? {}), |
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.
Here if author front matter has no social key, the result will be social: {}
.
If the key was absent before normalization, we'd rather keep it absent after normalization (unless it's an explicit goal of the normalization to always have an object for empty (in which case the normalized type shouldn't allow null/undefined anymore)
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'm +1 to make socials
required—unless we plan to make socials: null
and socials: {}
render different things, for which I cannot conceive a reason.
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 don't think we plan render those differently.
I also like to normalize to {}
for convenience of frontend code, although technically this slightly increases bundle size / memory by creating useless empty objects when we could use optional chaining. Maybe always normalizing to undefined would be better? That's really a detail so I'm fine with any of those.
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 don't think neither of those would be a concern when there aren't thousands of authors (by which time the blog posts' metadata is a far bigger concern).
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.
LGTM thanks 👍
oups, updated the branch and now we have test failures 😄 |
Motivation
Fix #10417
Test Plan
Local & CI
Test links
Deploy preview: https://deploy-preview-10424--docusaurus-2.netlify.app/