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
|
slorber
left a comment
There was a problem hiding this comment.
Need to move implementation to normalizeAuthor + add a few new tests for getBlogPostAuthors
| return authorInput; | ||
| return { | ||
| ...authorInput, | ||
| socials: normalizeSocials(authorInput.socials ?? {}), |
There was a problem hiding this comment.
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.
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.
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.
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).
|
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/