@madebywild/sanity-utils
v1.0.1
Published
> [!IMPORTANT] > This package is primarily intended for internal use.
Readme
[!IMPORTANT] This package is primarily intended for internal use.
@madebywild/sanity-utils
Utility helpers and UI primitives shared across Wild Sanity fields.
Install
pnpm add @madebywild/sanity-utilsConfigure Plugin
// No plugin setup required.Use in Schema
import { defineField } from "sanity";
import { requiredIf, visibleIf } from "@madebywild/sanity-utils";
const showIfKind = visibleIf("kind");
const requireIfKind = requiredIf("kind");
defineField({
name: "url",
type: "url",
// value can be boolean | string | string[]
...showIfKind(["external", "internal"]),
...requireIfKind("external", {
message: "URL is required for external links",
path: [],
}),
});import { createExcerptFromPortableText, dotPathToObjectValue } from "@madebywild/sanity-utils";
const sectionId = dotPathToObjectValue(document, "pageBuilder.sectionsArray.0.sectionSettings.sectionId.current");
const excerpt = createExcerptFromPortableText(value, 80);import { CompactObjectInput } from "@madebywild/sanity-utils/compact-object-input";
defineField({
name: "settings",
type: "object",
components: { input: CompactObjectInput },
});