57 lines
2.7 KiB
TypeScript
57 lines
2.7 KiB
TypeScript
import { defineField, defineType } from "sanity";
|
|
|
|
export const post = defineType({
|
|
name: "post",
|
|
title: "Post",
|
|
type: "document",
|
|
fields: [
|
|
defineField({ name: "title", title: "عنوان", type: "string", validation: (r) => r.required() }),
|
|
defineField({ name: "slug", title: "Slug", type: "slug", options: { source: "title" }, validation: (r) => r.required() }),
|
|
defineField({
|
|
name: "locale",
|
|
title: "زبان",
|
|
type: "string",
|
|
options: { list: [{ value: "fa", title: "فارسی" }, { value: "en", title: "English" }] },
|
|
initialValue: "fa",
|
|
validation: (r) => r.required(),
|
|
}),
|
|
defineField({
|
|
name: "category",
|
|
title: "دستهبندی",
|
|
type: "string",
|
|
options: {
|
|
list: [
|
|
{ value: "founder-notes", title: "یادداشتهای بنیانگذار" },
|
|
{ value: "marketing-branding", title: "بازاریابی و برندینگ" },
|
|
{ value: "product-thinking", title: "تفکر محصول" },
|
|
{ value: "tech-builds", title: "ساختهای فنی" },
|
|
{ value: "business-experiments", title: "آزمایشهای کسبوکار" },
|
|
{ value: "systems-productivity", title: "سیستمها و بهرهوری" },
|
|
],
|
|
},
|
|
validation: (r) => r.required(),
|
|
}),
|
|
defineField({ name: "excerpt", title: "خلاصه", type: "text", rows: 3 }),
|
|
defineField({ name: "coverImage", title: "تصویر کاور", type: "image", options: { hotspot: true }, fields: [defineField({ name: "alt", type: "string", title: "Alt text" })] }),
|
|
defineField({ name: "body", title: "متن", type: "array", of: [{ type: "block" }, { type: "image", options: { hotspot: true } }, { type: "code" }] }),
|
|
defineField({ name: "tags", title: "تگها", type: "array", of: [{ type: "reference", to: [{ type: "tag" }] }] }),
|
|
defineField({ name: "author", title: "نویسنده", type: "reference", to: [{ type: "author" }] }),
|
|
defineField({ name: "publishedAt", title: "تاریخ انتشار", type: "datetime" }),
|
|
defineField({ name: "featured", title: "برگزیده", type: "boolean", initialValue: false }),
|
|
defineField({
|
|
name: "seo",
|
|
title: "SEO",
|
|
type: "object",
|
|
fields: [
|
|
defineField({ name: "title", type: "string", title: "عنوان SEO" }),
|
|
defineField({ name: "description", type: "text", title: "توضیحات", rows: 2 }),
|
|
defineField({ name: "ogImage", type: "image", title: "تصویر OG" }),
|
|
],
|
|
}),
|
|
],
|
|
preview: {
|
|
select: { title: "title", subtitle: "category", media: "coverImage" },
|
|
},
|
|
orderings: [{ title: "تاریخ انتشار", name: "publishedAtDesc", by: [{ field: "publishedAt", direction: "desc" }] }],
|
|
});
|