From 25f85e49057be9275349ed36e4bb024e8225463a Mon Sep 17 00:00:00 2001 From: christinaroise Date: Fri, 13 Sep 2024 11:50:28 +0200 Subject: [PATCH 1/2] add seo config with fallback seo --- studio/schema.ts | 2 + studio/schemas/deskStructure.ts | 37 ++++++++++++++----- studio/schemas/documents/admin/fallbackSeo.ts | 32 ++++++++++++++++ studio/schemas/objects/seo.ts | 6 +-- 4 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 studio/schemas/documents/admin/fallbackSeo.ts diff --git a/studio/schema.ts b/studio/schema.ts index fd2d3ad9d..83e3136e7 100644 --- a/studio/schema.ts +++ b/studio/schema.ts @@ -15,6 +15,7 @@ import companyLocation from "./schemas/documents/companyLocation"; import compensations from "./schemas/documents/compensations"; import redirect from "./schemas/documents/redirect"; import benefitsByLocation from "./schemas/objects/compensations/benefitsByLocation"; +import seoFallback from "./schemas/documents/admin/fallbackSeo"; export const schema: { types: SchemaTypeDefinition[] } = { types: [ @@ -34,5 +35,6 @@ export const schema: { types: SchemaTypeDefinition[] } = { redirect, benefitsByLocation, companyLocation, + seoFallback, ], }; diff --git a/studio/schemas/deskStructure.ts b/studio/schemas/deskStructure.ts index 1881fc885..4f8a44a26 100644 --- a/studio/schemas/deskStructure.ts +++ b/studio/schemas/deskStructure.ts @@ -12,6 +12,7 @@ import { CaseIcon, DoubleChevronRightIcon, PinIcon, + SearchIcon, } from "@sanity/icons"; import { soMeLinksID } from "./documents/socialMediaProfiles"; import { companyInfoID } from "./documents/companyInfo"; @@ -19,6 +20,7 @@ import { legalDocumentID } from "./documents/legalDocuments"; import { compensationsId } from "./documents/compensations"; import { redirectId } from "./documents/redirect"; import { companyLocationID } from "./documents/companyLocation"; +import { seoFallbackID } from "./documents/admin/fallbackSeo"; // Admin Section const adminSection = (S: StructureBuilder) => @@ -36,21 +38,21 @@ const adminSection = (S: StructureBuilder) => S.document() .schemaType(companyInfoID) .documentId(companyInfoID) - .title("Company Information"), + .title("Company Information") ), S.listItem() .title("Company Locations") .icon(PinIcon) .child( - S.documentTypeList(companyLocationID).title("Company Locations"), + S.documentTypeList(companyLocationID).title("Company Locations") ), S.listItem() .title("Legal Documents") .icon(CogIcon) .child( - S.documentTypeList(legalDocumentID).title("Legal Documents"), + S.documentTypeList(legalDocumentID).title("Legal Documents") ), - ]), + ]) ); // Site Settings Section @@ -69,13 +71,30 @@ const siteSettingSection = (S: StructureBuilder) => S.document() .schemaType("navigationManager") .documentId("navigationManager") - .title("Navigation Manager"), + .title("Navigation Manager") ), S.listItem() .title("Social Media Profiles") .icon(UsersIcon) .child( - S.document().schemaType(soMeLinksID).documentId(soMeLinksID), + S.document().schemaType(soMeLinksID).documentId(soMeLinksID) + ), + S.listItem() + .title("SEO Configurations") + .icon(SearchIcon) + .child( + S.list() + .title("SEO Configurations") + .items([ + S.listItem() + .title("Fallback SEO") + .child( + S.document() + .schemaType(seoFallbackID) + .documentId(seoFallbackID) + .title("Fallback SEO") + ), + ]) ), S.listItem() .title("Broken Links") @@ -83,7 +102,7 @@ const siteSettingSection = (S: StructureBuilder) => .child(S.documentTypeList(redirectId).title("Redirects")), //TODO: Add SEO Settings //TODO: Add Language selector - ]), + ]) ); // Section for dynamic and customizable Pages @@ -118,9 +137,9 @@ const SpecialPagesSection = (S: StructureBuilder) => S.document() .schemaType(compensationsId) .documentId(compensationsId) - .title("Compensations"), + .title("Compensations") ), - ]), + ]) ); // Main export diff --git a/studio/schemas/documents/admin/fallbackSeo.ts b/studio/schemas/documents/admin/fallbackSeo.ts new file mode 100644 index 000000000..6508d876d --- /dev/null +++ b/studio/schemas/documents/admin/fallbackSeo.ts @@ -0,0 +1,32 @@ +import { defineField, defineType } from "sanity"; +import seo from "studio/schemas/objects/seo"; + +export const seoFallbackID = "seoFallback"; + +const seoFallback = defineType({ + name: seoFallbackID, + type: "document", + title: "SEO Configurations", + description: + "Configure global settings for your site including brand assets, tracking codes, and default SEO settings.", + fields: [ + defineField({ + ...seo, + title: "Default SEO Settings", + description: + "If page-specific SEO settings are not provided, these settings will be applied as default.", + options: { + collapsible: false, + }, + }), + ], + preview: { + prepare() { + return { + title: "SEO Configurations", + }; + }, + }, +}); + +export default seoFallback; diff --git a/studio/schemas/objects/seo.ts b/studio/schemas/objects/seo.ts index 010bd39e3..82b9a9903 100644 --- a/studio/schemas/objects/seo.ts +++ b/studio/schemas/objects/seo.ts @@ -1,4 +1,4 @@ -import { defineField, StringInputProps } from "sanity"; +import { defineField } from "sanity"; import { StringInputWithCharacterCount } from "studio/components/stringInputWithCharacterCount/StringInputWithCharacterCount"; const seoFieldID = { @@ -45,12 +45,12 @@ const seo = defineField({ rule .min(70) .warning( - "A description of at least 70 characters has a higher chance of converting visitors", + "A description of at least 70 characters has a higher chance of converting visitors" ), rule .max(160) .warning( - "A description of more than 160 characters has a lower chance of converting visitors", + "A description of more than 160 characters has a lower chance of converting visitors" ), ], components: { From 7e9f0c01d667df289f14c6feaa0d8cd71b251d55 Mon Sep 17 00:00:00 2001 From: christinaroise Date: Fri, 13 Sep 2024 11:52:38 +0200 Subject: [PATCH 2/2] fix lint --- studio/schemas/deskStructure.ts | 22 +++++++++++----------- studio/schemas/objects/seo.ts | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/studio/schemas/deskStructure.ts b/studio/schemas/deskStructure.ts index 4f8a44a26..5acb0b0f9 100644 --- a/studio/schemas/deskStructure.ts +++ b/studio/schemas/deskStructure.ts @@ -38,21 +38,21 @@ const adminSection = (S: StructureBuilder) => S.document() .schemaType(companyInfoID) .documentId(companyInfoID) - .title("Company Information") + .title("Company Information"), ), S.listItem() .title("Company Locations") .icon(PinIcon) .child( - S.documentTypeList(companyLocationID).title("Company Locations") + S.documentTypeList(companyLocationID).title("Company Locations"), ), S.listItem() .title("Legal Documents") .icon(CogIcon) .child( - S.documentTypeList(legalDocumentID).title("Legal Documents") + S.documentTypeList(legalDocumentID).title("Legal Documents"), ), - ]) + ]), ); // Site Settings Section @@ -71,13 +71,13 @@ const siteSettingSection = (S: StructureBuilder) => S.document() .schemaType("navigationManager") .documentId("navigationManager") - .title("Navigation Manager") + .title("Navigation Manager"), ), S.listItem() .title("Social Media Profiles") .icon(UsersIcon) .child( - S.document().schemaType(soMeLinksID).documentId(soMeLinksID) + S.document().schemaType(soMeLinksID).documentId(soMeLinksID), ), S.listItem() .title("SEO Configurations") @@ -92,9 +92,9 @@ const siteSettingSection = (S: StructureBuilder) => S.document() .schemaType(seoFallbackID) .documentId(seoFallbackID) - .title("Fallback SEO") + .title("Fallback SEO"), ), - ]) + ]), ), S.listItem() .title("Broken Links") @@ -102,7 +102,7 @@ const siteSettingSection = (S: StructureBuilder) => .child(S.documentTypeList(redirectId).title("Redirects")), //TODO: Add SEO Settings //TODO: Add Language selector - ]) + ]), ); // Section for dynamic and customizable Pages @@ -137,9 +137,9 @@ const SpecialPagesSection = (S: StructureBuilder) => S.document() .schemaType(compensationsId) .documentId(compensationsId) - .title("Compensations") + .title("Compensations"), ), - ]) + ]), ); // Main export diff --git a/studio/schemas/objects/seo.ts b/studio/schemas/objects/seo.ts index 82b9a9903..2bf1ecbee 100644 --- a/studio/schemas/objects/seo.ts +++ b/studio/schemas/objects/seo.ts @@ -45,12 +45,12 @@ const seo = defineField({ rule .min(70) .warning( - "A description of at least 70 characters has a higher chance of converting visitors" + "A description of at least 70 characters has a higher chance of converting visitors", ), rule .max(160) .warning( - "A description of more than 160 characters has a lower chance of converting visitors" + "A description of more than 160 characters has a lower chance of converting visitors", ), ], components: {