Configuration
import { defineConfig } from "sanity";
import { fusion } from "@codedazur/sanity-plugin-fusion";
export default defineConfig({
//...
plugins: [
// ...
fusion(),
],
});Routes
fusion({
routes: ["myPage"],
});Themes
fusion({
themes: [
{ value: "light", title: "Light" },
{ value: "dark", title: "Dark" },
],
});Aspect Ratios
fusion({
aspectRatios: ["16:9", "4:3"],
});Sections
import { defineConfig } from "sanity";
import { mySectionSchema } from "./schemas//mySectionSchema";
export default defineConfig({
fusion({
sections: [mySectionSchema],
}),
});Adding a Section
fusion({
sections(schemas) {
return [...schemas, mySectionSchema].sort((a, b) =>
a.name.localeCompare(b.name),
);
},
});Removing a Section
fusion({
sections(sections) {
return sections.filter(
(schema) => schema.name !== SectionType.ImageSection,
);
},
});Fields
Mutating an Existing Field
export default defineConfig({
fusion({
fields: (schemas) => schemas.map((schema) => {
if (schema.name === FieldType.Theme && isStringDefinition(schema)) {
schema.hidden = false;
if (schema.options?.list?.length === 0) {
schema.readOnly = true;
}
schema.options?.list?.unshift({
title: "Inherit",
value: undefined,
});
}
return schema;
}),
});import { BaseSchemaDefinition, StringDefinition } from "sanity";
function isStringDefinition(
field: BaseSchemaDefinition,
): field is StringDefinition {
return "type" in field && field.type === "string";
}Reference
| Option | Type | Required | Description |
|---|---|---|---|
routes | string[] | Yes | An array of strings, where each string is the name of a Sanity document type in your schema that represents a navigable page or route (e.g., ["page", "article"]). |
sections | BaseSchemaDefinition[] | ((defaultSections: BaseSchemaDefinition[]) => BaseSchemaDefinition[]) | No | Allows customization of the page section schemas. |
fields | BaseSchemaDefinition[] | ((defaultFields: BaseSchemaDefinition[]) => BaseSchemaDefinition[]) | No | Allows customization of the field-level schemas. |
themes | TitledListValue<string>[] | No | An array of objects { title: string, value: string } defining custom themes for selection in the Studio. The value should be the CSS class name of a theme (preferably an imported Vanilla Extract theme class name if your themes are managed this way). |
aspectRatios | string[] | No | An array of strings defining allowed aspect ratios using colons (e.g., ["16:9", "4:3"]). Defaults to a list from fusion-ui. |
Last updated on