@madebywild/sanity-page-builder
v1.3.0
Published
> [!IMPORTANT] > This package is primarily intended for internal use.
Readme
[!IMPORTANT] This package is primarily intended for internal use.
@madebywild/sanity-page-builder
Composable page-builder field with reusable section factories.
Install
pnpm add @madebywild/sanity-page-builderConfigure Plugin
import { defineConfig, defineField } from "sanity";
import { wildSanityPageBuilderPlugin } from "@madebywild/sanity-page-builder";
import { createSection } from "@madebywild/sanity-page-builder/utils";
import { createSection as textOnlySection } from "@madebywild/sanity-page-builder/sections/text-only";
import { createSection as mediaOnlySection } from "@madebywild/sanity-page-builder/sections/media-only";
const customSection = defineField({
name: "customHero",
type: "object",
title: "Custom Hero",
fields: [defineField({ name: "title", type: "string" })],
});
export default defineConfig({
plugins: [
wildSanityPageBuilderPlugin({
sections: [
textOnlySection(),
mediaOnlySection(),
createSection(customSection, {
sectionKind: "hero",
isLibrarySection: false,
isShareableSection: true,
}),
],
// "Global" settings for each section.
sectionSettings: [
defineField({ name: "background", type: "string", title: "Background" }),
],
previewImageUrl: (sectionName) => `/static/sections/${sectionName}.png`,
}),
],
});Use in Schema
import { defineField } from "sanity";
defineField({
name: "pageBuilder",
type: "wild.pageBuilder",
options: {
allowedSections: [
"wild.pageBuilder.section.textOnly",
"wild.pageBuilder.section.mediaOnly",
"customHero",
],
disallowedSections: ["wild.pageBuilder.section.mediaOnly"],
},
});