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: integrate with VTEX headless CMS #104

Closed
wants to merge 15 commits into from

Conversation

danzanzini
Copy link
Contributor

@danzanzini danzanzini commented Jun 9, 2022

What's the purpose of this pull request?

This PR adds CMS capabilities to gatsby.store. It addresses mostly parts of the CMS Spike. This PR:

  • Integrates gatsby.store with storeframework vtex store;
  • Renders one component using CMS (global alert)
  • Renders one page using cms (/cms)
  • Adds page rendered to lighthouse tests

The script to remove all cms related code is not done but will be tackled later.

How does it work?

Firstly, I followed the cms tutorial to integrate gatsby.store with storeframework, then I followed the structure already created at storeframework.store to render things using CMS data.

Regarding code architecture

Since we want to easily remove CMS-related code from the repo, I've added CMS components and pages in the same structure already used for non-cms stuff. i.e:

  • index page without cms: pages/index.tsx
  • index page with cms: pages/cms/index.tsx
  • global alert component without cms: components/common/Alert
  • global alert component with cms: components/cms/common/Alert

This way, it'd be easy to create a script that removes all cms-related code and overwrites it properly.

How to test it?

Open the preview link. The global alert should be working with the message defined at the CMS. Which says: Alert from master. The link should send to /office.

You should also want to visit /cms and see if it's everything fine.

References

https://www.faststore.dev/tutorials/cms-overview
https://github.com/vtex-sites/storeframework.store

Checklist

You may erase this after checking them all ;)

Changelog

  • Added an entry in the CHANGELOG.md at the beginning of its due section. The latest version should comes first.
  • Added the PR number with the PR link at the entry in the CHANGELOG.md. E.g., New items in the pull_request_template.md (#12)

PR Description

  • Added a label according to the PR goal - Breaking change, Enhancement, Bug or Chore.
  • Added the component, hook, or pathname in-between backticks (``) - If applicable. E.g., ComponentName component.
  • Identified the function or parameter in the PR - If applicable. E.g., useWindowDimensions hook.

Documentation

  • PR description
  • Added to/Updated the Storybook - if applicable.
  • For documentation changes, ping @ carolinamenezes, @ PedroAntunesCosta or @ Mariana-Caetano to review and update.

@vercel
Copy link

vercel bot commented Jun 9, 2022

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

Name Status Preview Updated
gatsby-store-storybook ✅ Ready (Inspect) Visit Preview Jul 19, 2022 at 2:51PM (UTC)

@vtex-sites
Copy link

vtex-sites bot commented Jun 9, 2022

Preview is ready

This pull request generated a Preview

👀   Preview: https://sfj-bc92bb2--gatsby.preview.vtex.app
🔬   Go deeper by inspecting the Build Logs
📝   based on commit bc92bb2

@vtex-sites
Copy link

vtex-sites bot commented Jun 9, 2022

Lighthouse Reports

Here are the Lighthouse reports of this Pull Request

📝 Based on commit bc92bb2

Lighthouse Report by page
📎   /
📎   /apple-magic-mouse/p
📎   /office
📎   /cms

@danzanzini danzanzini marked this pull request as ready for review June 30, 2022 13:54
@danzanzini danzanzini changed the title [WIP] feat: integrate with cms feat: integrate with VTEX headless CMS Jun 30, 2022
Copy link
Contributor

@ArthurTriis1 ArthurTriis1 left a comment

Choose a reason for hiding this comment

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

LGTM! And the tests worked fine!

Copy link
Contributor

@tlgimenes tlgimenes left a comment

Choose a reason for hiding this comment

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

Ok. I liked the strategy, however, I don't see us using the same strategy on Next.JS or similar. I'd rather go with a strategy we don't use the gatsby-plugin-cms and useStaticQuery. Also, I found it weird to have components specific for cms com components/cms

I'm leaning towards having a first class integration between CMS and the starter on the pages folder so that it's easy to remove by changing the pages folder

@@ -1,5 +1,5 @@
import { lazy, Suspense } from 'react'
import Alert from 'src/components/common/Alert'
import Alert from 'src/components/cms/common/Alert'
Copy link
Contributor

Choose a reason for hiding this comment

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

This is weird. We have a CMS component affecting non CMS pages, since Layout.tsx is being imported on gatsby-browser.tsx.

Copy link
Contributor

@icazevedo icazevedo left a comment

Choose a reason for hiding this comment

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

I agree with Gimenes' points. Will we be doing this in future iterations of this feature?

@ArthurTriis1 ArthurTriis1 mentioned this pull request Aug 15, 2022
8 tasks
@filipewl
Copy link
Contributor

I believe we can close this one in favor of #172.

@filipewl filipewl closed this Aug 16, 2022
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.

None yet

5 participants