From adf5c1749c245ddf1170494ed7fd472dc31ce0e5 Mon Sep 17 00:00:00 2001 From: Mitchell Christ Date: Fri, 2 Aug 2024 17:33:26 -0700 Subject: [PATCH] add descriptions and update schema previews --- sanity/schemas/documents/announcement.ts | 7 +++-- sanity/schemas/documents/logo.ts | 6 ++-- sanity/schemas/documents/page.ts | 11 ++++++- sanity/schemas/documents/redirect.tsx | 34 ++++++++++++++-------- sanity/schemas/documents/site.ts | 37 +++++++++++++----------- sanity/schemas/documents/testimonial.ts | 4 +-- sanity/schemas/objects/link.ts | 4 ++- sanity/schemas/objects/metadata.ts | 1 + sanity/src/structure.ts | 6 ++-- src/types/Sanity.d.ts | 2 +- 10 files changed, 71 insertions(+), 41 deletions(-) diff --git a/sanity/schemas/documents/announcement.ts b/sanity/schemas/documents/announcement.ts index 6526304..0d93777 100644 --- a/sanity/schemas/documents/announcement.ts +++ b/sanity/schemas/documents/announcement.ts @@ -1,5 +1,5 @@ import { defineField, defineType } from 'sanity' -import { VscMegaphone } from 'react-icons/vsc' +import { VscMegaphone, VscCalendar } from 'react-icons/vsc' import { getBlockText } from '@sanity/src/utils' export default defineType({ @@ -41,10 +41,13 @@ export default defineType({ select: { content: 'content', cta: 'cta.label', + start: 'start', + end: 'end', }, - prepare: ({ content, cta }) => ({ + prepare: ({ content, cta, start, end }) => ({ title: getBlockText(content), subtitle: cta, + media: (start || end) && VscCalendar, }), }, }) diff --git a/sanity/schemas/documents/logo.ts b/sanity/schemas/documents/logo.ts index 8e0691b..f9c1425 100644 --- a/sanity/schemas/documents/logo.ts +++ b/sanity/schemas/documents/logo.ts @@ -1,10 +1,10 @@ import { defineField, defineType } from 'sanity' -import { VscSymbolMisc } from 'react-icons/vsc' +import { VscVerified } from 'react-icons/vsc' export default defineType({ name: 'logo', title: 'Logo', - icon: VscSymbolMisc, + icon: VscVerified, type: 'document', fields: [ defineField({ @@ -24,10 +24,12 @@ export default defineType({ }), defineField({ name: 'light', + description: 'On dark backgrounds', type: 'image', }), defineField({ name: 'dark', + description: 'On light backgrounds', type: 'image', }), ], diff --git a/sanity/schemas/documents/page.ts b/sanity/schemas/documents/page.ts index 467e634..b4b6fe3 100644 --- a/sanity/schemas/documents/page.ts +++ b/sanity/schemas/documents/page.ts @@ -1,4 +1,5 @@ import { defineField, defineType } from 'sanity' +import { VscHome, VscEyeClosed, VscQuestion } from 'react-icons/vsc' export default defineType({ name: 'page', @@ -17,6 +18,7 @@ export default defineType({ }), defineField({ name: 'modules', + description: 'Page content', type: 'array', of: [ { type: 'accordion-list' }, @@ -54,10 +56,17 @@ export default defineType({ select: { title: 'title', slug: 'metadata.slug.current', + media: 'metadata.image', + noindex: 'metadata.noIndex', }, - prepare: ({ title, slug }) => ({ + prepare: ({ title, slug, media, noindex }) => ({ title, subtitle: slug && (slug === 'index' ? '/' : `/${slug}`), + media: + media || + (slug === 'index' && VscHome) || + (slug === '404' && VscQuestion) || + (noindex && VscEyeClosed), }), }, }) diff --git a/sanity/schemas/documents/redirect.tsx b/sanity/schemas/documents/redirect.tsx index 41901a6..34279c3 100644 --- a/sanity/schemas/documents/redirect.tsx +++ b/sanity/schemas/documents/redirect.tsx @@ -9,28 +9,38 @@ export default defineType({ fields: [ defineField({ name: 'source', + title: 'Redirect from', + placeholder: 'e.g. /old-path, /old-blog/:slug', type: 'string', - placeholder: '/, /blog/:path*, etc', }), defineField({ name: 'destination', + title: 'Redirect to', + placeholder: 'e.g. /new-path, /blog/:slug', type: 'string', - placeholder: '/, /blog/:path*, etc', - description: ( - - Next.js Documentation - - ), }), defineField({ name: 'permanent', type: 'boolean', initialValue: true, - description: - 'If true will use the 308 status code which instructs clients/search engines to cache the redirect forever, if false will use the 307 status code which is temporary and is not cached.', + description: ( + <> +

+ If true will use the 308 status code which instructs + clients/search engines to cache the redirect forever, if{' '} + false will use the 307 status code which is temporary + and is not cached. +

+

+ + Next.js redirects documentation + +

+ + ), }), ], preview: { diff --git a/sanity/schemas/documents/site.ts b/sanity/schemas/documents/site.ts index 3a04820..420544e 100644 --- a/sanity/schemas/documents/site.ts +++ b/sanity/schemas/documents/site.ts @@ -2,7 +2,7 @@ import { defineField, defineType } from 'sanity' export default defineType({ name: 'site', - title: 'Site', + title: 'Site settings', type: 'document', groups: [ { name: 'general', title: 'General', default: true }, @@ -29,26 +29,17 @@ export default defineType({ type: 'array', of: [{ type: 'reference', to: [{ type: 'announcement' }] }], group: 'general', - description: 'Higher order has higher precedence', + description: + 'One announcement shown at a time. Top items have higher precedence.', }), defineField({ name: 'ctas', - title: 'Call-to-action', + title: 'Call-to-action (Site-wide)', + description: 'Typically used in the header and/or footer.', type: 'array', of: [{ type: 'cta' }], group: 'general', }), - defineField({ - name: 'copyright', - type: 'array', - of: [ - { - type: 'block', - styles: [{ title: 'Normal', value: 'normal' }], - }, - ], - group: 'general', - }), defineField({ name: 'headerMenu', type: 'reference', @@ -67,17 +58,29 @@ export default defineType({ to: [{ type: 'navigation' }], group: 'navigation', }), + defineField({ + name: 'copyright', + type: 'array', + of: [ + { + type: 'block', + styles: [{ title: 'Normal', value: 'normal' }], + }, + ], + group: 'general', + }), defineField({ name: 'ogimage', - title: 'Open Graph Image (global)', - description: 'Used for social sharing previews', + title: 'Open Graph Image (Site-wide)', + description: + 'Used for social sharing previews. Set page-specific images in Page documents.', type: 'image', group: 'general', }), ], preview: { prepare: () => ({ - title: 'Site', + title: 'Site settings', }), }, }) diff --git a/sanity/schemas/documents/testimonial.ts b/sanity/schemas/documents/testimonial.ts index 508acae..e9ff1a0 100644 --- a/sanity/schemas/documents/testimonial.ts +++ b/sanity/schemas/documents/testimonial.ts @@ -41,8 +41,8 @@ export default defineType({ author: 'author', }, prepare: ({ content, author }) => ({ - title: getBlockText(content), - subtitle: author?.name || author?.title || 'No author', + title: author?.name || author?.title || 'No author', + subtitle: getBlockText(content), media: author?.image, }), }, diff --git a/sanity/schemas/objects/link.ts b/sanity/schemas/objects/link.ts index 6056800..acac4a1 100644 --- a/sanity/schemas/objects/link.ts +++ b/sanity/schemas/objects/link.ts @@ -33,6 +33,7 @@ export default defineType({ }), defineField({ name: 'external', + placeholder: 'https://example.com', type: 'url', validation: (Rule) => Rule.uri({ @@ -43,7 +44,8 @@ export default defineType({ }), defineField({ name: 'params', - title: 'URL params', + title: 'URL parameters', + placeholder: 'e.g. #jump-link or ?foo=bar', type: 'string', hidden: ({ parent }) => parent?.type !== 'internal', }), diff --git a/sanity/schemas/objects/metadata.ts b/sanity/schemas/objects/metadata.ts index 49b4998..1fbca75 100644 --- a/sanity/schemas/objects/metadata.ts +++ b/sanity/schemas/objects/metadata.ts @@ -3,6 +3,7 @@ import { defineField, defineType } from 'sanity' export default defineType({ name: 'metadata', title: 'Metadata', + description: 'For search engines', type: 'object', fields: [ defineField({ diff --git a/sanity/src/structure.ts b/sanity/src/structure.ts index f9ee2d3..686b5ec 100644 --- a/sanity/src/structure.ts +++ b/sanity/src/structure.ts @@ -1,15 +1,15 @@ import { group, singleton } from './utils' import type { StructureResolver } from 'sanity/structure' -import { VscServerProcess } from 'react-icons/vsc' +import { VscMultipleWindows, VscServerProcess } from 'react-icons/vsc' import { BsDatabaseAdd } from 'react-icons/bs' const structure: StructureResolver = (S, context) => S.list() .title('Content') .items([ - singleton(S, 'site').icon(VscServerProcess), - S.documentTypeListItem('page').title('Pages'), + singleton(S, 'site').title('Site settings').icon(VscServerProcess), + S.documentTypeListItem('page').title('Pages').icon(VscMultipleWindows), S.divider(), S.documentTypeListItem('navigation'), diff --git a/src/types/Sanity.d.ts b/src/types/Sanity.d.ts index 5b27475..6679855 100644 --- a/src/types/Sanity.d.ts +++ b/src/types/Sanity.d.ts @@ -10,10 +10,10 @@ declare global { logo?: Logo announcements?: Announcement[] ctas?: CTA[] - copyright?: any headerMenu?: Navigation footerMenu?: Navigation social?: Navigation + copyright?: any ogimage?: string }>