Skip to content

Commit

Permalink
feat: 🏗️ AT-33(BE): Add schema types for all contents.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kene-Okoye committed Mar 10, 2024
1 parent fcc9f9c commit f8df499
Show file tree
Hide file tree
Showing 18 changed files with 1,210 additions and 1 deletion.
27 changes: 26 additions & 1 deletion afrotreff-content-management/sanity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {defineConfig} from 'sanity'
import {structureTool} from 'sanity/structure'
import {visionTool} from '@sanity/vision'
import {schemaTypes} from './schemaTypes'
import {documentInternationalization} from '@sanity/document-internationalization'
import {listStructure} from './deskStructure'

export default defineConfig({
name: 'default',
Expand All @@ -10,7 +12,30 @@ export default defineConfig({
projectId: '5ir4p4o5',
dataset: 'production',

plugins: [structureTool(), visionTool()],
plugins: [
structureTool({structure: listStructure}),
visionTool(),
documentInternationalization({
// Required configuration
supportedLanguages: [
{id: 'de', title: 'German'},
{id: 'en', title: 'English'},
],
schemaTypes: [
'homePage',
'visionAndTeamPage',
'activitiesPage',
'getInvolvedPage',
'FAQPage',
'albumsPage',
'blogPage',
'post',
'author',
'category',
],
languageField: `language`,
}),
],

schema: {
types: schemaTypes,
Expand Down
52 changes: 52 additions & 0 deletions afrotreff-content-management/schemaTypes/author.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {BsPersonWorkspace} from 'react-icons/bs'

export default {
name: 'author',
title: 'Author',
type: 'document',
icon: BsPersonWorkspace,

fields: [
{
name: 'name',
title: 'Name',
type: 'string',
},
{
name: 'slug',
title: 'Slug',
type: 'slug',
options: {
source: 'name',
maxLength: 96,
},
},
{
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: [],
},
],
},
],
preview: {
select: {
title: 'name',
media: 'image',
},
},
}
67 changes: 67 additions & 0 deletions afrotreff-content-management/schemaTypes/blockContent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import {defineType, defineArrayMember} from 'sanity'

/**
* This is the schema definition for the rich text fields used for
* for this blog studio. When you import it in schemas.js it can be
* reused in other parts of the studio with:
* {
* name: 'someName',
* title: 'Some title',
* type: 'blockContent'
* }
*/
export default defineType({
title: 'Block Content',
name: 'blockContent',
type: 'array',
of: [
defineArrayMember({
title: 'Block',
type: 'block',
// Styles let you set what your user can mark up blocks with. These
// correspond with HTML tags, but you can set any title or value
// you want and decide how you want to deal with it where you want to
// use your content.
styles: [
{title: 'Normal', value: 'normal'},
{title: 'H1', value: 'h1'},
{title: 'H2', value: 'h2'},
{title: 'H3', value: 'h3'},
{title: 'H4', value: 'h4'},
{title: 'Quote', value: 'blockquote'},
],
lists: [{title: 'Bullet', value: 'bullet'}],
// Marks let you mark up inline text in the block editor.
marks: {
// Decorators usually describe a single property – e.g. a typographic
// preference or highlighting by editors.
decorators: [
{title: 'Strong', value: 'strong'},
{title: 'Emphasis', value: 'em'},
],
// Annotations can be any object structure – e.g. a link or a footnote.
annotations: [
{
title: 'URL',
name: 'link',
type: 'object',
fields: [
{
title: 'URL',
name: 'href',
type: 'url',
},
],
},
],
},
}),
// You can add additional types here. Note that you can't use
// primitive types such as 'string' and 'number' in the same array
// as a block type.
defineArrayMember({
type: 'image',
options: {hotspot: true},
}),
],
})
24 changes: 24 additions & 0 deletions afrotreff-content-management/schemaTypes/category.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {MdCategory} from 'react-icons/md'

export default {
name: 'category',
title: 'Category',
type: 'document',
initialValue: {previewTitle: 'Get Involved Page'},
icon: MdCategory,

fields: [
{
name: 'title',
title: 'Title',
type: 'string',
options: {
list: [
{title: 'News', value: 'news'},
{title: 'Story', value: 'story'},
{title: 'Interviews', value: 'interviews'},
],
},
},
],
}
24 changes: 24 additions & 0 deletions afrotreff-content-management/schemaTypes/countryFlag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {FaFlag} from 'react-icons/fa'

export default {
name: 'countryFlag',
title: 'Country Flag',
type: 'document',
icon: FaFlag,

fields: [
{
name: 'nameOfCountry',
title: 'Name Of Country',
type: 'string',
},
{
name: 'imageOfCountryFlag',
title: 'Image Of Country Flag',
type: 'image',
options: {
hotspot: true,
},
},
],
}
30 changes: 30 additions & 0 deletions afrotreff-content-management/schemaTypes/heroSection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {PiFlagBannerFill} from 'react-icons/pi'

export default {
name: 'heroSection',
title: 'Hero Section',
type: 'document',
icon: PiFlagBannerFill,

fields: [
{
name: 'backgroundImage',
title: 'Background image',
type: 'image',
validation: (rule: {required: () => any}) => rule.required(),
options: {
hotspot: true,
},
},
{
name: 'headingText',
title: 'Heading text',
type: 'string',
},
{
name: 'smallText',
title: 'Small text',
type: 'string',
},
],
}
37 changes: 37 additions & 0 deletions afrotreff-content-management/schemaTypes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import blockContent from './blockContent'
import category from './category'
import post from './post'
import author from './author'
import hero from './heroSection'
import smallLargeHeading from './smallLargeHeading'

// Schemas for The Tnidividual Pages
import homePage from './pages/homePage'
import visionAndTeamPage from './pages/visionAndTeamPage'
import teamBio from './pages/teamBio'
import activitiesPage from './pages/activitiesPage'
import FAQPage from './pages/FAQPage'
import getInvolvedPage from './pages/getInvolvedPage'
import albumsPage from './pages/albumsPage'
import yearlyAlbum from './pages/yearlyAlbum'
import countryFlag from './countryFlag'
import blogPage from './pages/blogPage'

export const schemaTypes = [
post,
author,
category,
blockContent,
hero,
smallLargeHeading,
yearlyAlbum,
countryFlag,
teamBio,
homePage,
visionAndTeamPage,
activitiesPage,
getInvolvedPage,
FAQPage,
albumsPage,
blogPage,
]
92 changes: 92 additions & 0 deletions afrotreff-content-management/schemaTypes/pages/FAQPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import {FcFaq} from 'react-icons/fc'

export default {
name: 'FAQPage',
title: 'FAQ Page',
type: 'document',
initialValue: {previewTitle: 'FAQ Page'},
icon: FcFaq,

fields: [
/*-------------------------
* Mandatory Fields
*------------------------*/
{
name: 'PreviewTitle',
title: 'preview Title',
type: 'string',
description: `Please enter a title for the document.
This would be used for the preview header content found on the left hand side tab`,
// hidden: true,
validation: (rule: {required: () => any}) => rule.required(),
},
{
name: 'language',
title: 'Language',
type: 'string',
readOnly: true,
},

/*-------------------------
* Other Fields
*------------------------*/
{
name: 'heroSection_Faq',
title: 'HERO SECTION - FAQ',
type: 'heroSection',
},
{
name: 'questionAndAnswersSection',
title: 'QUESTION AND ANSWERS SECTION',
type: 'object',
fields: [
{
name: 'heading',
title: 'Heading',
type: 'string',
},
{
name: 'qandAs',
title: 'Q & As',
type: 'array',
of: [
{
type: 'object',
fields: [
{
name: 'question',
title: 'Question',
type: 'text',
},
{
name: 'answer',
title: 'Answer',
type: 'text',
},
],
},
],
},
],
},
],

preview: {
select: {
previewTitle: 'previewTitle',
language: 'language',
},
prepare(selection: {previewTitle: string; language: string}) {
const {previewTitle, language} = selection
const LANGUAGES: {[key: string]: string} = {
en: 'English',
de: 'German',
}
return {
...selection,
title: previewTitle && language && `${previewTitle} - ${language.toUpperCase()}`,
subtitle: language && `FAQ page translation for ${LANGUAGES[language]}`,
}
},
},
}
Loading

0 comments on commit f8df499

Please sign in to comment.