Initial commit

This commit is contained in:
Waylon Walker 2019-05-09 10:15:41 -05:00
commit 5a3bf52ebb
86 changed files with 2639 additions and 0 deletions

View file

@ -0,0 +1,17 @@
export default {
name: 'category',
type: 'document',
title: 'Category',
fields: [
{
name: 'title',
type: 'string',
title: 'Title'
},
{
name: 'description',
type: 'text',
title: 'Description'
}
]
}

View file

@ -0,0 +1,41 @@
import MdPerson from 'react-icons/lib/md/person'
export default {
name: 'person',
type: 'document',
title: 'Person',
icon: MdPerson,
fields: [
{
name: 'name',
type: 'string',
title: 'Name'
},
{
name: 'slug',
type: 'slug',
title: 'Slug',
description: 'Some frontend will require a slug to be set to be able to show the person',
options: {
source: 'name',
maxLength: 96
}
},
{
name: 'image',
title: 'Image',
type: 'figure'
},
{
name: 'bio',
title: 'Bio',
type: 'bioPortableText'
}
],
preview: {
select: {
title: 'name',
media: 'image'
}
}
}

View file

@ -0,0 +1,90 @@
import {format} from 'date-fns'
export default {
name: 'project',
title: 'Project',
type: 'document',
fields: [
{
name: 'title',
title: 'Title',
type: 'string'
},
{
name: 'slug',
title: 'Slug',
type: 'slug',
description: 'Some frontend will require a slug to be set to be able to show the project',
options: {
source: 'title',
maxLength: 96
}
},
{
name: 'publishedAt',
title: 'Published at',
description: 'You can use this field to schedule projects where you show them',
type: 'datetime'
},
{
name: 'excerpt',
title: 'Excerpt',
type: 'simplePortableText'
},
{
name: 'members',
title: 'Members',
type: 'array',
of: [{type: 'projectMember'}]
},
{
name: 'startedAt',
title: 'Started at',
type: 'datetime'
},
{
name: 'endedAt',
title: 'Ended at',
type: 'datetime'
},
{
name: 'mainImage',
title: 'Main image',
type: 'figure'
},
{
name: 'categories',
title: 'Categories',
type: 'array',
of: [{type: 'reference', to: {type: 'category'}}]
},
{
name: 'body',
title: 'Body',
type: 'projectPortableText'
},
{
name: 'relatedProjects',
title: 'Related projects',
type: 'array',
of: [{type: 'reference', to: {type: 'project'}}]
}
],
preview: {
select: {
title: 'title',
publishedAt: 'publishedAt',
slug: 'slug',
media: 'mainImage'
},
prepare ({title = 'No title', publishedAt, slug, media}) {
const dateSegment = format(publishedAt, 'YYYY/MM')
const path = `/${dateSegment}/${slug.current}/`
return {
title,
media,
subtitle: publishedAt ? path : 'Missing publishing date'
}
}
}
}

View file

@ -0,0 +1,35 @@
export default {
name: 'siteSettings',
type: 'document',
title: 'Site Settings',
fields: [
{
name: 'title',
type: 'string',
title: 'Title'
},
{
name: 'description',
type: 'text',
title: 'Description',
description: 'Describe your portfolio for search engines and social media.'
},
{
name: 'keywords',
type: 'array',
title: 'Keywords',
description: 'Add keywords that describes your portfolio.',
of: [{type: 'string'}],
options: {
layout: 'tags'
}
},
{
name: 'author',
type: 'reference',
description: 'Publish an author and set a reference to them here.',
title: 'Author',
to: [{type: 'person'}]
}
]
}

View file

@ -0,0 +1,34 @@
export default {
name: 'bioPortableText',
type: 'array',
title: 'Excerpt',
of: [
{
title: 'Block',
type: 'block',
styles: [{title: 'Normal', value: 'normal'}],
lists: [],
marks: {
decorators: [
{title: 'Strong', value: 'strong'},
{title: 'Emphasis', value: 'em'},
{title: 'Code', value: 'code'}
],
annotations: [
{
name: 'link',
type: 'object',
title: 'URL',
fields: [
{
title: 'URL',
name: 'href',
type: 'url'
}
]
}
]
}
}
]
}

View file

@ -0,0 +1,34 @@
export default {
name: 'figure',
title: 'Image',
type: 'image',
options: {
hotspot: true
},
fields: [
{
title: 'Caption',
name: 'caption',
type: 'string',
options: {
isHighlighted: true
}
},
{
name: 'alt',
type: 'string',
title: 'Alternative text',
validation: Rule => Rule.error('You have to fill out the alternative text.').required(),
description: 'Important for SEO and accessiblity.',
options: {
isHighlighted: true
}
}
],
preview: {
select: {
imageUrl: 'asset.url',
title: 'caption'
}
}
}

View file

@ -0,0 +1,42 @@
export default {
type: 'object',
name: 'projectMember',
title: 'Project Member',
fields: [
{
title: 'Person',
name: 'person',
type: 'reference',
to: {type: 'person'}
},
{
title: 'Roles',
name: 'roles',
type: 'array',
of: [{type: 'string'}],
options: {
layout: 'radio',
list: [
{title: 'Designer', value: 'designer'},
{title: 'Developer', value: 'developer'},
{title: 'Editor', value: 'editor'},
{title: 'Manager', value: 'manager'}
]
}
}
],
preview: {
select: {
personName: 'person.name',
roles: 'roles',
media: 'person.image'
},
prepare (data) {
return {
...data,
title: data.personName,
subtitle: data.roles && data.roles.join('/')
}
}
}
}

View file

@ -0,0 +1,51 @@
export default {
title: 'Portable Text',
name: 'projectPortableText',
type: 'array',
of: [
{
title: 'Block',
type: 'block',
// Styles let you set what your user can mark up blocks with. These
// corrensponds 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.
{
type: 'figure'
}
]
}

View file

@ -0,0 +1,39 @@
/**
* 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: 'simplePortableText'
* }
*/
export default {
title: 'Portable Text',
name: 'simplePortableText',
type: 'array',
of: [
{
title: 'Block',
type: 'block',
// Styles let you set what your user can mark up blocks with. These
// corrensponds 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'}],
lists: [],
// 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'},
{title: 'Code', value: 'code'}
],
// Annotations can be any object structure e.g. a link or a footnote.
annotations: []
}
}
]
}

41
studio/schemas/schema.js Normal file
View file

@ -0,0 +1,41 @@
// First, we must import the schema creator
import createSchema from 'part:@sanity/base/schema-creator'
// Then import schema types from any plugins that might expose them
import schemaTypes from 'all:part:@sanity/base/schema-type'
// Document types
import category from './documents/category'
import person from './documents/person'
import project from './documents/project'
import siteSettings from './documents/siteSettings'
// Object types
import bioPortableText from './objects/bioPortableText'
import figure from './objects/figure'
import projectMember from './objects/projectMember'
import projectPortableText from './objects/projectPortableText'
import simplePortableText from './objects/simplePortableText'
// Then we give our schema to the builder and provide the result to Sanity
export default createSchema({
// We name our schema
name: 'portfolio',
// Then proceed to concatenate our our document type
// to the ones provided by any plugins that are installed
types: schemaTypes.concat([
// When added to this list, object types can be used as
// { type: 'typename' } in other document schemas
bioPortableText,
figure,
projectMember,
projectPortableText,
simplePortableText,
// The following are document types which will appear
// in the studio.
category,
person,
project,
siteSettings
])
})