Kapehe
Developer Relations at Sanity
Kapehe is located at Las Vegas, NV
export default {
name: "chef",
title: "Chef",
type: "document",
fields: [
{
name: "name",
title: "Chef's Name",
type: "string",
},
{
name: "image",
title: "Image",
type: "image",
options: {
hotspot: true,
},
},
{
name: "bio",
title: "Bio",
type: "array",
of: [
{
title: "Block",
type: "block",
styles: [{ title: "Normal", value: "normal" }],
lists: [],
},
],
},
],
};
export default {
title: "Ingredient",
name: "ingredient",
type: "document",
fields: [
{
title: "Name",
name: "name",
type: "string",
},
{
title: "Image",
name: "image",
type: "image",
option: {
hotspot: true,
},
},
{
title: "Notes",
name: "notes",
type: "text",
},
],
};
export default {
name: "recipe",
title: "Recipe",
type: "document",
fields: [
{
name: "name",
Title: "Recipe Name",
type: "string",
},
{
name: "slug",
title: "Slug",
type: "slug",
options: {
source: "title",
maxLength: 96,
},
},
{
name: "chef",
title: "Chef",
type: "reference",
to: { type: "chef" },
},
{
name: "mainImage",
title: "Recipe Main Image",
type: "image",
options: {
hotspot: true,
},
},
{
name: "ingredient",
title: "Ingredient",
type: "array",
of: [
{
type: "object",
fields: [
{
title: "Ingredient",
name: "ingredient",
type: "reference",
to: [{ type: "ingredient" }],
},
{
name: "wholeNumber",
title: "Whole Numbers",
type: "number",
},
{
name: "fraction",
title: "Fraction Amount",
type: "string",
options: {
list: ["1/2", "1/3", "1/4", "3/4", "2/3"],
},
},
{
name: "unit",
title: "Unit",
type: "string",
options: {
list: ["grams", "cup", "Tbsp.", "tsp."],
},
},
],
preview: {
select: {
title: "ingredient.name",
name: "ingredient.name",
media: "ingredient.image",
fraction: "fraction",
unit: "unit",
},
prepare({
title,
subtitle,
media,
fraction = "(No fraction set)",
unit = "(No unit set)",
}) {
return {
title,
subtitle: `${fraction} ${unit}`,
media,
};
},
},
},
],
},
{
name: "instructions",
title: "Instructions",
type: "array",
of: [{ type: "block" }],
},
{
name: "likes",
title: "Likes",
type: "number",
},
],
initialValue: {
likes: 0,
},
};
These three schemas are the beginning schemas for a website that has recipes with ingredients and a chef.
recipe.js
references the two other schemas.
Developer Relations at Sanity