Skip to content

Commit

Permalink
use latest sdk and update interface, server context new api (BuilderI…
Browse files Browse the repository at this point in the history
  • Loading branch information
teleaziz authored Dec 4, 2023
1 parent 0cd8ff2 commit a5218a6
Show file tree
Hide file tree
Showing 10 changed files with 4,577 additions and 4,564 deletions.
2 changes: 1 addition & 1 deletion components/cart/CartSidebarView/CartSidebarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import env from '@config/env'
const CartSidebarView: FC = () => {
const checkoutUrl = useCheckoutUrl()
const cart = useCart()
const subTotal = cart?.subtotalPrice
const subTotal = (cart?.subtotalPrice as any)?.amount || cart?.subtotalPrice || '-';
const total = ' - '

const items = cart?.lineItems ?? []
Expand Down
2 changes: 1 addition & 1 deletion components/common/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Layout: React.FC<{ pageProps: any; children: React.ReactNode }> = ({
const builderTheme = pageProps.theme
return (
<CommerceProvider {...shopifyConfig}>
<BuilderContent isStatic content={builderTheme} modelName="theme">
<BuilderContent content={builderTheme} modelName="theme">
{(data, loading) => {
if (loading && !builderTheme) {
return 'loading ...'
Expand Down
2 changes: 1 addition & 1 deletion lib/resolve-builder-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export async function resolveBuilderContent(
let page = await builder
.get(modelName, {
apiKey: builderConfig.apiKey,
enrich: true,
options: {
locale,
includeRefs: true,
// only cachebust if you're statically generating the page
cachebust: true,
},
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
]
},
"dependencies": {
"@builder.io/react": "^3.0.14",
"@builder.io/react": "^3.1.1",
"@builder.io/utils": "1.1.10",
"@builder.io/widgets": "1.2.24",
"@emotion/react": "^11.10.6",
Expand Down
2 changes: 1 addition & 1 deletion pages/[[...path]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export default function Path({
/>
)}
<BuilderComponent
options={{ includeRefs: true }}
options={{ enrich: true }}
model="page"
data={{ theme }}
context={{
Expand Down
10 changes: 10 additions & 0 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import Document, {
} from 'next/document'
import cheerio from 'cheerio'

import { Builder } from '@builder.io/react';
import ivm from 'isolated-vm'

/**
* Run content code bindings in SSR context
*/
const isolate = new ivm.Isolate({ memoryLimit: 128 });
const context = isolate.createContextSync();
Builder.setServerContext(context);

/**
* See this issue for more details https://github.com/emotion-js/emotion/issues/2040
* Theme-ui using emotion which render styles inside template tags causing it not to apply when rendering
Expand Down
3 changes: 1 addition & 2 deletions pages/collection/[handle].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ export default function Handle({
<h1>Loading...</h1>
) : (
<BuilderComponent
isStatic
key={collection.id}
options={{ includeRefs: true }}
options={{ enrich: true }}
model={builderModel}
data={{ collection, theme }}
content={page}
Expand Down
3 changes: 1 addition & 2 deletions pages/product/[handle].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,9 @@ export default function Handle({
<h1>Loading...</h1>
) : (
<BuilderComponent
isStatic
key={product!.id}
model={builderModel}
options={{ includeRefs: true }}
options={{ enrich: true }}
data={{ product, theme }}
content={page}
/>
Expand Down
Loading

0 comments on commit a5218a6

Please sign in to comment.