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

feat(core): Support SSG when the cart is non-empty #724

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

christensenep
Copy link
Contributor

What/Why?

Move the cart badge icon (indicating the number of items in the cart) to a client component, allowing us to drop the requirement that the user must not have a cart yet in order to support static routes. Now, the static pages are generated with empty carts, and when the client CartBadge component is initially rendered, it fetches the cart quantity from a new API endpoint. Revalidation of data still works as it did previously.

Testing

Tested locally and in a vercel preview build, verifying that the transition from empty cart -> populated cart works correctly, as well as subsequent additions to the cart.

@christensenep christensenep requested a review from a team as a code owner April 2, 2024 20:41
Copy link

changeset-bot bot commented Apr 2, 2024

🦋 Changeset detected

Latest commit: bc34a01

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Apr 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
catalyst-latest ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2024 11:21pm
catalyst-testbed ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 3, 2024 11:21pm
4 Ignored Deployments
Name Status Preview Comments Updated (UTC)
catalyst-1millionproducts-store ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2024 11:21pm
catalyst-au ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2024 11:21pm
catalyst-storybook ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2024 11:21pm
catalyst-uk ⬜️ Ignored (Inspect) Visit Preview Apr 3, 2024 11:21pm

apps/core/app/api/cart-quantity/route.ts Outdated Show resolved Hide resolved
apps/core/components/header/cart-badge.tsx Outdated Show resolved Hide resolved
apps/core/components/header/cart.tsx Show resolved Hide resolved
@bookernath
Copy link
Contributor

Thanks to @bobbyshaw for the feedback in #647 that led us down the path to improve this

Copy link
Contributor

github-actions bot commented Apr 3, 2024

⚡️🏠 Lighthouse report

Lighthouse ran against https://catalyst-latest-n9xl1u9c2-bigcommerce-platform.vercel.app

🖥️ Desktop

We ran Lighthouse against the changes on a desktop and produced this report. Here's the summary:

Category Score
🟢 Performance 100
🟢 Accessibility 100
🟠 Best practices 78
🟢 SEO 90

📱 Mobile

We ran Lighthouse against the changes on a mobile and produced this report. Here's the summary:

Category Score
🟢 Performance 97
🟢 Accessibility 100
🟠 Best practices 78
🟢 SEO 92

@christensenep christensenep added this pull request to the merge queue Apr 5, 2024
Merged via the queue into main with commit 045cd14 Apr 5, 2024
15 checks passed
@christensenep christensenep deleted the cart-client-component branch April 5, 2024 23:00
This was referenced Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants