diff --git a/studio/deskStructure.ts b/studio/deskStructure.ts index a72c47273..cfc5ba0d4 100644 --- a/studio/deskStructure.ts +++ b/studio/deskStructure.ts @@ -1,7 +1,6 @@ import { CaseIcon, CogIcon, - DoubleChevronRightIcon, EarthGlobeIcon, HeartIcon, ImagesIcon, @@ -24,7 +23,6 @@ import { compensationsId } from "./schemas/documents/compensations"; import { languageSettingsID } from "./schemas/documents/languageSettings"; import { pageBuilderID } from "./schemas/documents/pageBuilder"; import { brandAssetsID } from "./schemas/documents/siteSettings/brandAssets"; -import { brokenLinkID } from "./schemas/documents/siteSettings/brokenLink"; import { localeID } from "./schemas/documents/siteSettings/locale"; import { soMeLinksID } from "./schemas/documents/siteSettings/socialMediaProfiles"; import { customerCasesPageID } from "./schemas/documents/specialPages/customerCasesPage"; @@ -122,10 +120,6 @@ const siteSettingSection = (S: StructureBuilder) => .documentId(defaultSeoID) .title("Default SEO"), ), - S.listItem() - .title("Broken Links") - .icon(DoubleChevronRightIcon) - .child(S.documentTypeList(brokenLinkID).title("Redirects")), ]), ); diff --git a/studio/schema.ts b/studio/schema.ts index 51c3e0f4f..7deb2a0ce 100644 --- a/studio/schema.ts +++ b/studio/schema.ts @@ -10,7 +10,6 @@ import languageSettings from "./schemas/documents/languageSettings"; import pageBuilder from "./schemas/documents/pageBuilder"; import posts from "./schemas/documents/post"; import brandAssets from "./schemas/documents/siteSettings/brandAssets"; -import brokenLink from "./schemas/documents/siteSettings/brokenLink"; import locale from "./schemas/documents/siteSettings/locale"; import navigationManager from "./schemas/documents/siteSettings/navigationManager"; import socialMediaLinks from "./schemas/documents/siteSettings/socialMediaProfiles"; @@ -40,7 +39,6 @@ export const schema: { types: SchemaTypeDefinition[] } = { legalDocument, compensations, customerCasesPage, - brokenLink, benefitsByLocation, companyLocation, defaultSeo, diff --git a/studio/schemas/documents/siteSettings/brokenLink.ts b/studio/schemas/documents/siteSettings/brokenLink.ts deleted file mode 100644 index edfcc3d00..000000000 --- a/studio/schemas/documents/siteSettings/brokenLink.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { SanityDocument, SlugRule } from "@sanity/types"; -import { type Slug, defineField, defineType } from "sanity"; - -import PrefixedSlugInput from "studio/components/slug/PrefixedSlugInput"; -import { blogId } from "studio/schemas/documents/blog"; -import { compensationsId } from "studio/schemas/documents/compensations"; -import { pageBuilderID } from "studio/schemas/documents/pageBuilder"; - -const slugRequired = (rule: SlugRule) => - rule.required().custom((value: Slug | undefined) => { - if (!value || !value.current) return "Can't be blank"; - return true; - }); - -const requiredIfDestinationType = ( - type: string, - document: SanityDocument | undefined, - value: unknown, -) => { - const destination = document?.destination; - if ( - typeof destination === "object" && - destination !== null && - "type" in destination && - destination.type === type && - value === undefined - ) { - return "Can't be blank"; - } - return true; -}; - -export const brokenLinkID = "brokenLink"; - -const brokenLink = defineType({ - name: brokenLinkID, - title: "Broken Links", - type: "document", - fields: [ - defineField({ - name: "source", - title: "Source", - description: "The url slug to be redirected to the destination", - type: "slug", - validation: (rule) => slugRequired(rule), - components: { - input: (props) => PrefixedSlugInput({ prefix: "/", ...props }), - }, - }), - defineField({ - name: "destination", - title: "Destination", - type: "object", - fields: [ - defineField({ - name: "type", - title: "Type", - type: "string", - initialValue: "reference", - options: { - layout: "radio", - list: [ - { value: "reference", title: "Internal Page" }, - { value: "external", title: "External URL" }, - ], - }, - }), - defineField({ - name: "reference", - title: "Internal Page", - description: "Where should the user be redirected?", - type: "reference", - to: [ - { type: pageBuilderID }, - { type: blogId }, - { type: compensationsId }, - ], - hidden: ({ parent }) => parent?.type !== "reference", - validation: (rule) => - rule.custom((value, { document }) => - requiredIfDestinationType("reference", document, value), - ), - }), - defineField({ - name: "external", - title: "External URL", - description: "Where should the user be redirected?", - type: "url", - hidden: ({ parent }) => parent?.type !== "external", - validation: (rule) => - rule.custom((value, { document }) => - requiredIfDestinationType("external", document, value), - ), - }), - ], - }), - ], - preview: { - select: { - sourceSlug: "source.current", - destinationType: "destination.type", - destinationReferenceSlug: "destination.reference.slug.current", - destinationExternalURL: "destination.external", - }, - prepare({ - sourceSlug, - destinationType, - destinationReferenceSlug, - destinationExternalURL, - }) { - if ( - typeof sourceSlug !== "string" || - typeof destinationType !== "string" || - (destinationType === "reference" && - typeof destinationReferenceSlug !== "string") || - (destinationType === "external" && - typeof destinationExternalURL !== "string") - ) { - return {}; - } - const destination = { - reference: `/${destinationReferenceSlug}`, - external: destinationExternalURL, - }[destinationType]; - const title = - sourceSlug && destination - ? `/${sourceSlug} → ${destination}` - : undefined; - return { - title, - subtitle: { - reference: "Internal", - external: "External", - }[destinationType], - }; - }, - }, -}); - -export default brokenLink; diff --git a/studio/schemas/schemaTypes/slug.ts b/studio/schemas/schemaTypes/slug.ts index 1e054fd0b..d17bcbecf 100644 --- a/studio/schemas/schemaTypes/slug.ts +++ b/studio/schemas/schemaTypes/slug.ts @@ -90,7 +90,7 @@ function createSlugField(source: string) { "Enter a unique URL path for the page. This path will be used in the website's address bar. " + "A URL path, also known as a slug, is a URL-friendly version of the page title, used to create " + "a human-readable and search engine optimized URL for the content. " + - "Note that the slug can not be changed after publication, but alternative slugs can be defined via Redirects.", + "Note that the slug can not be changed after publication.", options: { source, maxLength: SLUG_MAX_LENGTH, @@ -114,8 +114,6 @@ function createSlugField(source: string) { to avoid breaking shared links if document is already draft, this is handled through validation instead - - if new slugs are needed, redirects can be used instead */ return document !== undefined && isPublished(document); },