RFC: Override page component #25
Replies: 2 comments 1 reply
-
Note that at the moment there is a "hack" to get similar behavior where there are parts of the page that aren't editable. It looks something like this: import { RuntimeProvider, Document as DocumentComponent } from '@makeswift/runtime/react'
export default function Page({ pageId, rootElement, makeswiftApiEndpoint }: PageProps) {
return (
<RuntimeProvider
defaultRootElements={new Map([[pageId, rootElement]])}
makeswiftApiEndpoint={makeswiftApiEndpoint}
>
<main>
{/* <Header /> is a code component that's not registered with Makeswift. */}
<Header />
<DocumentComponent documentKey={pageId} />
{/* <Footer /> is a code component that's not registered with Makeswift. */}
<Footer />
</main>
</RuntimeProvider>
)
} You would then use this page component instead of using the one exported by |
Beta Was this translation helpful? Give feedback.
-
What if I want to only have one page use the custom page? I would still want the custom page to be available in the Makeswift UI, but other pages to use the base Makeswift page. |
Beta Was this translation helpful? Give feedback.
-
Background
We've heard feedback from @cfofiu that it would be nice if a developer could set up a page in Makeswift in a way such that the Makeswift user can only edit specific sections of the page. This would be useful to lock things down or incrementally adopt Makeswift for an existing page.
Proposal
When building a Makeswift page, the root element is automatically created and looks roughly something like this:
While we need a root element to get the page started, the
Page
component that renders that element would be overridable in the Makeswift runtime. It could look something like this:By allowing the page component to be overwritten, it becomes possible to create a custom page component that exposes certain sections. i.e.:
The example above would allow the
top
andbottom
sections to be editable in the Makeswift builder but everything else would not be editable since it's just plain React, not registered with Makeswift in any way.Backwards Compatibility
This is a new feature that wouldn't affect existing APIs so it should be backwards compatible.
Release Timeline
This is in the idea stage and requires the
Slot
control to be released before it can be useful. There's not a specific timeline on this at the time of writing.Feedback
We would love to hear your feedback on this idea and whether it works for your team and why.
Beta Was this translation helpful? Give feedback.
All reactions