BuilderIO / builder-shopify-hydrogen

Builder.io Visual CMS + page builder example with Shopify Hydrogen
77 stars 33 forks source link

Builder is not woking on other pages other than the /builder folder. How do we fix this #10

Open hitpixel opened 1 year ago

hitpixel commented 1 year ago

Builder is not working on other pages other than the /builder folder. How do we fix this?

Builder.io only works on the builder/ folder, so any pages out side of this folder would not work, unable to edit normal pages such as /pages/about us or homepage as well.

How would I fix this or what code would I need to input to [handle].server.tsx ? I cant publish or edit page as the page shows 404 for new pages made, or it will show the page for the pages on shopify but unable to edit them,

Any help is appreciated.

mrkoreye commented 1 year ago

Hi @hitpixel. In order to use Builder on other directories/folders/routes, you will need to add logic to the folder's route handler that queries Builder and then renders the content. This example project has Builder integrated for any route with /builder/<some-page> because of this route handler: https://github.com/BuilderIO/builder-shopify-hydrogen/blob/main/src/routes/builder/%5Bhandle%5D.server.tsx

If you want other routes to display Builder content, you will need to copy the route handler code, and add it to the route you want to use Builder on. For example, if you want Builder to handle all pages in the /pages directory (route), you can replace this file with the content in the Builder route handler code. Another approach you can take if you would like to have some pages coming from Shopify and some from Builder, is that you can add the Builder query logic to the current /pages route handler and show Builder content if Builder content exists, and show Shopify page content if not.

As far as editing landing pages built in the Shopify admin goes, you will need to edit those in Shopify. They are not editable in Builder. If you would like to edit and create all pages in Builder instead, you need to replace the /pages logic entirely so it only fetches pages created in Builder.

I hope this information helps!