Skip to content

refactor(theme): split BlogPostItem into smaller theme subcomponents#7716

Merged
slorber merged 18 commits intomainfrom
slorber/split-blog-post-item
Jul 8, 2022
Merged

refactor(theme): split BlogPostItem into smaller theme subcomponents#7716
slorber merged 18 commits intomainfrom
slorber/split-blog-post-item

Conversation

@slorber
Copy link
Collaborator

@slorber slorber commented Jul 1, 2022

Breaking changes

The blog theme components have been significantly refactored, similarly to docs (#7644)

  • @theme/BlogPostItem has been split into much smaller components, easier to swizzle
  • Most blog item components do not receive data as props anymore
  • You can access data anywhere in blog post subtrees with a hook const {metadata, frontMatter} = useBlogPost()
  • Import the hook: import {useBlogPost} from '@docusaurus/theme-common/internal';
  • metadata.truncated => metadata.hasTruncateMarker
  • @theme/BlogPostAuthor => @theme/BlogPostItem/Header/Author
  • @theme/BlogPostAuthors => @theme/BlogPostItem/Header/Authors

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

Motivation

Continue the process of splitting larger theme components into smaller subcomponents easier to swizzle

Test Plan

ci + preview

These links should be strictly identical to what it looked like before:

Blog list:

Blog post:

Site changelog:

Site changelog entry:

Test links

Deploy preview: https://deploy-preview-7716--docusaurus-2.netlify.app/

Related issues/PRs

#7644

@slorber slorber requested review from Josh-Cena and lex111 as code owners July 1, 2022 16:51
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 1, 2022
@slorber slorber added the pr: breaking change Existing sites may not build successfully in the new version. Description contains more details. label Jul 1, 2022
@netlify
Copy link

netlify bot commented Jul 1, 2022

[V2]

Name Link
🔨 Latest commit fbb8393
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/62c80cfc8b39870008460279
😎 Deploy Preview https://deploy-preview-7716--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Jul 1, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟠 69 🟢 100 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 74 🟢 100 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

github-actions bot commented Jul 1, 2022

Size Change: -469 B (0%)

Total Size: 804 kB

Filename Size Change
website/build/assets/css/styles.********.css 106 kB -469 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 52.6 kB
website/build/assets/js/main.********.js 607 kB
website/build/index.html 38.9 kB

compressed-size-action

@slorber slorber marked this pull request as draft July 1, 2022 17:05
@slorber
Copy link
Collaborator Author

slorber commented Jul 1, 2022

WIP: will likely add a useBlogPostItem() hook later

@slorber slorber marked this pull request as ready for review July 7, 2022 15:18
Copy link
Collaborator Author

@slorber slorber left a comment

Choose a reason for hiding this comment

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

Added some review comments

Copy link
Collaborator

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

LGTM

@slorber slorber merged commit c3ff131 into main Jul 8, 2022
@slorber slorber deleted the slorber/split-blog-post-item branch July 8, 2022 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA pr: breaking change Existing sites may not build successfully in the new version. Description contains more details.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants