-
Notifications
You must be signed in to change notification settings - Fork 0
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
Improve rendering of site #351
Conversation
as the preview forces the rendering to by dynamic
const PagePreview: React.FunctionComponent = () => { | ||
const iFrameBridge = useIFrameBridge(); | ||
|
||
const { fetch, graphQLFetch } = useBlockPreviewFetch(graphQLApiUrl); | ||
|
||
const [blockData, setBlockData] = useState<PageContentBlockData>(); | ||
useEffect(() => { | ||
async function load() { | ||
if (!iFrameBridge.block) { | ||
setBlockData(undefined); | ||
return; | ||
} | ||
const newData = await recursivelyLoadBlockData({ | ||
blockType: "PageContent", | ||
blockData: iFrameBridge.block, | ||
graphQLFetch, | ||
fetch, | ||
}); | ||
setBlockData(newData); | ||
} | ||
load(); | ||
}, [iFrameBridge.block, fetch, graphQLFetch]); | ||
|
||
return <div>{blockData && <PageContentBlock data={blockData} />}</div>; | ||
}; | ||
|
||
const StagePreview = () => { | ||
const { block: stage } = useIFrameBridge(); | ||
return stage ? <StageBlock data={stage} /> : null; | ||
}; | ||
|
||
const previewComponents = { | ||
page: PagePreview, | ||
stage: StagePreview, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this preview components into separate files? Otherwise this file may get rather large when having many different previews
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we go: #353
next-runtime-env
as it prevents static rendering (use context inlayout.tsx
instead)config.ts
layout.tsx
files for block preview and siteSupersedes #350 and #349
To discuss:
SiteConfigsProvider.tsx
andSiteConfigProvider.tsx
to @comet/cms-site?Ways to access the current SiteConfig
Use
await getSiteConfigForDomain(params.domain)
Not possible, instead pass the necessary data from the page
Use the
useSiteConfig()
-hook