Skip to content

Commit

Permalink
add seo config with fallback seo
Browse files Browse the repository at this point in the history
  • Loading branch information
christinaroise committed Sep 13, 2024
1 parent 67f0689 commit 25f85e4
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 12 deletions.
2 changes: 2 additions & 0 deletions studio/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -34,5 +35,6 @@ export const schema: { types: SchemaTypeDefinition[] } = {
redirect,
benefitsByLocation,
companyLocation,
seoFallback,
],
};
37 changes: 28 additions & 9 deletions studio/schemas/deskStructure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import {
CaseIcon,
DoubleChevronRightIcon,
PinIcon,
SearchIcon,
} from "@sanity/icons";
import { soMeLinksID } from "./documents/socialMediaProfiles";
import { companyInfoID } from "./documents/companyInfo";
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) =>
Expand All @@ -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
Expand All @@ -69,21 +71,38 @@ 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")
.icon(DoubleChevronRightIcon)
.child(S.documentTypeList(redirectId).title("Redirects")),
//TODO: Add SEO Settings
//TODO: Add Language selector
]),
])
);

// Section for dynamic and customizable Pages
Expand Down Expand Up @@ -118,9 +137,9 @@ const SpecialPagesSection = (S: StructureBuilder) =>
S.document()
.schemaType(compensationsId)
.documentId(compensationsId)
.title("Compensations"),
.title("Compensations")
),
]),
])
);

// Main export
Expand Down
32 changes: 32 additions & 0 deletions studio/schemas/documents/admin/fallbackSeo.ts
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 3 additions & 3 deletions studio/schemas/objects/seo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineField, StringInputProps } from "sanity";
import { defineField } from "sanity";
import { StringInputWithCharacterCount } from "studio/components/stringInputWithCharacterCount/StringInputWithCharacterCount";

const seoFieldID = {
Expand Down Expand Up @@ -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: {
Expand Down

0 comments on commit 25f85e4

Please sign in to comment.