Page Builder
The Page Builder is a powerful drag-and-drop tool for creating dynamic page layouts using pre-defined blocks.
Components
PageRenderer
The PageRenderer component is responsible for rendering the final page content based on the JSON structure.
import { PageRenderer } from '@orbitusdev/components/page-builder';
import type { PageContentData } from '@orbitusdev/business/schemas/page-block';
const content: PageContentData = {
blocks: [
{ id: '1', type: 'hero', order: 0, data: { title: 'Welcome' } },
{ id: '2', type: 'content', order: 1, data: { text: 'Hello World' } }
]
};
export default function MyPage() {
return <PageRenderer content={content} />;
}PageEditor
The PageEditor provides a visual interface for managing page blocks. It handles adding, removing, reordering, and editing blocks.
'use client';
import { PageEditor } from '@orbitusdev/components/page-builder';
export default function EditorPage({ initialContent }) {
const handleSave = async (data) => {
await saveToBackend(data);
};
return (
<PageEditor
pageId="123"
locale="en"
initialContent={initialContent}
onSave={handleSave}
/>
);
}Available Blocks
The Page Builder currently supports the following blocks:
| Type | Label | Description |
|---|---|---|
hero | Hero | Large banner section with title and CTA |
features | Features | Grid of features or benefits |
content | Content | Rich text/HTML content |
cta | Call to Action | Action-focused section with buttons |
image | Image | Optimized image with caption |
video | Video | Embedded video from YouTube/Vimeo |
testimonials | Testimonials | Customer testimonials carousel/grid |
faq | FAQ | Accordion-style frequently asked questions |
spacer | Spacer | Vertical spacing |
Architecture
- Registry:
registry.tsmaps block types to their definitions and components. - State: The editor uses local state for instantaneous updates and propagates changes via
onSave. - Drag & Drop: Powered by
@dnd-kitfor accessible and performant drag-and-drop interactions.
Customizable Blocks
To add a new block:
- Create the block component in
blocks/. - Define its schema in
@orbitusdev/business. - Register it in
registry.tsandPageRenderer.
Last updated on