Skip to content

Commit

Permalink
feat: add SEO sanity type to custom types
Browse files Browse the repository at this point in the history
  • Loading branch information
Aerilym committed Oct 1, 2024
1 parent 4b62a15 commit 195fbab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/sanity-cms/lib/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { DesktopIcon, EditIcon, RocketIcon } from '@sanity/icons';
const iframeDefaultOptions = {
url: {
origin: 'same-origin',
preview: (document: RouteSchemaType) => document?.slug?.current ?? new Error('Missing slug'),
preview: (document: RouteFieldsSchemaType) =>
document?.slug?.current ?? new Error('Missing slug'),
draftMode: '/api/draft/enable', // the route you enable draft mode, see: https://github.com/sanity-io/visual-editing/tree/main/packages/preview-url-secret#sanitypreview-url-secret
},
showDisplayUrl: true,
Expand Down
3 changes: 2 additions & 1 deletion packages/sanity-cms/schemas/fields/groups/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ export const routeFields = [
validation: (Rule) => Rule.required(),
}),
];
export type RouteSchemaType = SchemaFieldsType<typeof routeFields>;

export type RouteFieldsSchemaType = SchemaFieldsType<typeof routeFields>;
4 changes: 2 additions & 2 deletions packages/sanity-cms/schemas/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { GenericSchemaType, SchemaFields } from '@session/sanity-types';
import type { SeoType } from './fields/basic/seo';

type CustomFieldTypeMap = {
//TODO: type this
seoMetaFields: 'string';
seoMetaFields: SeoType;
};

export type SchemaFieldsType<Fields extends SchemaFields<CustomFieldTypeMap>> = GenericSchemaType<
Expand Down

0 comments on commit 195fbab

Please sign in to comment.