Skip to content

Commit

Permalink
add TagsSection schema
Browse files Browse the repository at this point in the history
  • Loading branch information
milewskibogumil committed Oct 17, 2024
1 parent c56613d commit 937b1db
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apps/sanity/schema/Components.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineType } from "sanity";
import SimpleCtaSection from "./components/SimpleCtaSection";
import Faq from "./components/Faq";
import TagsSection from "./components/TagsSection";

export default defineType({
name: 'components',
Expand All @@ -9,6 +10,7 @@ export default defineType({
of: [
SimpleCtaSection,
Faq,
TagsSection,
],
options: {
insertMenu: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sanity/schema/components/Faq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sectionId from '../ui/sectionId';
import { toPlainText } from '../../utils/to-plain-text';

const name = 'Faq';
const title = 'FAQ';
const title = 'FAQ Section';
const icon = () => '❓';

export default defineField({
Expand Down
2 changes: 1 addition & 1 deletion apps/sanity/schema/components/SimpleCtaSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sectionId from '../ui/sectionId';
import { toPlainText } from '../../utils/to-plain-text';

const name = 'SimpleCtaSection';
const title = 'Simple CTA section';
const title = 'Simple CTA Section';
const icon = () => '🔗';

export default defineField({
Expand Down
57 changes: 57 additions & 0 deletions apps/sanity/schema/components/TagsSection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { defineField } from 'sanity';
import sectionId from '../ui/sectionId';
import { toPlainText } from '../../utils/to-plain-text';

const name = 'TagsSection';
const title = 'Tags Section';
const icon = () => '🏷️';

export default defineField({
name,
type: 'object',
title,
icon,
fields: [
defineField({
name: 'heading',
type: 'Heading',
title: 'Heading',
validation: Rule => Rule.required(),
}),
defineField({
name: 'largeText',
type: 'PortableText',
title: 'Large Text',
validation: Rule => Rule.required(),
}),
defineField({
name: 'paragraph',
type: 'PortableText',
title: 'Paragraph',
validation: Rule => Rule.required(),
}),
defineField({
name: 'tagsHeading',
type: 'Heading',
title: 'Tags Heading',
validation: Rule => Rule.required(),
}),
defineField({
name: 'tags',
type: 'array',
title: 'Tags',
of: [{ type: 'string' }],
validation: Rule => Rule.required(),
}),
...sectionId,
],
preview: {
select: {
heading: 'heading',
},
prepare: ({ heading }) => ({
title: title,
subtitle: toPlainText(heading),
}),
},
});
Binary file added apps/sanity/static/TagsSection.webp
Binary file not shown.

0 comments on commit 937b1db

Please sign in to comment.