I have a few questions about the general recommended workflow for using sections, but just to check my understanding is correct.
-
Sections are used to “centralise” components into the CMS and allow you to easily update the data they display in one place without having to go and update many page blocks. Also this leans nicely into split testing etc, as you can try out different variations of your sections from within the visual editor without any code changes. Sounds great so far
-
Sections do not replace “block” components, and are comprised of them.
So given these 2, then my workflow looks a bit like this
- Create a new section model
- Update your codebase to render the new section model where desired
- Create an instance of your section model “content”
- Use custom components or builder blocks to design and build it via the UI
It feels to me that step 2 should be redundant - I feel like we should be able to add sections to pages directly via the builder visual editor, therefore cutting out the need for the code integration.
Is there a way to do this?
Ideally all we should have to do for Builder integration is the recommended component
export function RenderBuilderContent<T>({
content,
model,
}: BuilderPageProps<T>) {
// Call the useIsPreviewing hook to determine if
// the page is being previewed in Builder
const isPreviewing = useIsPreviewing();
// If `content` has a value or the page is being previewed in Builder,
// render the BuilderComponent with the specified content and model props.
if (content || isPreviewing) {
return <BuilderComponent content={content as any} model={model} />;
}
// If the `content` is falsy and the page is
// not being previewed in Builder, render the
// DefaultErrorPage with a 404.
return <DefaultErrorPage statusCode={404} />;
}
And then use this component to render the “page”
From there builder should be able to hand-off all editting to the visual editor i would have thought,
Having to jump back into my codebase in order to integrate every section feels “wrong”
Maybe I’m just missing something?