Builder content link
Builder public api key
b7d943aa11124b3c97115ee1bf0aa52a
Gatsby Builder.Io Integration
I am unable to get the pre-view link to properly load in edit mode or live mode when building the production ready files to serve with Gatsbyjs. I have already followed all the basic from the docs here Getting the Preview URL Working - Builder.io and here Editing an Previewing Your Site - Builder.io. When I check http://localhost:8000/___graphql all the built pages using a graphQL query the test page from builder does not show up.
I followed the steps toggled Reload preview on URL path change to the off position and edited the 404.js.
In the browser console it shows that it is a 404, the page is blank, but I am able to make changes in the editor when the dev server is running (gatby develop).
Pictures
Code stack you are integrating Builder with
@Gatsby/5.12.9
â@builder.io/gatsbyâ: â^3.0.3â,
â@builder.io/reactâ: â^3.0.14â,
Gatsby-config.js
{
resolve: '@builder.io/gatsby',
options: {
// Replace with your Public API Key
publicAPIKey: "b7d943aa11124b3c97115ee1bf0aa52a",
useCache: false,
templates: {
// Render every `page` model as a new page using the
// src/templates/page.jsx template based on the URL provided in Builder.io
page: path.resolve('src/templates/page.jsx'),
}
}
},
page.jsx
import * as React from 'react';
import { builder, BuilderComponent } from '@builder.io/react'
import { graphql } from 'gatsby'
builder.init('b7d943aa11124b3c97115ee1bf0aa52a')
const MyComponent = (props) => {
const content = props.data?.allBuilderModels.oneMastercraft?.content;
return <BuilderComponent
content={content}
model="mastercraft" />
}
export default MyComponent;
export const query = graphql`
query($path: String!) {
allBuilderModels {
oneMastercraft(
target: { urlPath: $path }
options: { cachebust: true }
) { content }
}
}
`
404.js
import React from "react"
import { graphql } from "gatsby"
import Layout from "../components/layout"
import Seo from "../components/seo"
import { Builder, BuilderComponent } from '@builder.io/react';
const NotFoundPage = ({ data, location }) => {
const siteTitle = data.site.siteMetadata.title
if (Builder.isPreviewing || Builder.isEditing) {
return <BuilderComponent model="mastercraft" />
}
return (
<Layout location={location} title={siteTitle}>
<Seo title="404: Not Found" />
<h1>404: Not Found</h1>
<p>You just hit a route that doesn't exist... the sadness.</p>
</Layout>
)
}
export default NotFoundPage
export const pageQuery = graphql`
query {
site {
siteMetadata {
title
}
}
}
`