Skip to content

Commit

Permalink
add richtext as field translations
Browse files Browse the repository at this point in the history
  • Loading branch information
christinaroise committed Sep 26, 2024
1 parent 9458155 commit 36a46e8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions studio/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import benefitsByLocation from "./schemas/objects/compensations/benefitsByLocati
import { footerSection } from "./schemas/objects/footerSection";
import { link } from "./schemas/objects/link";
import { socialMedia } from "./schemas/objects/socialMedia";
import { richText } from "./schemas/fields/text";

export const schema: { types: SchemaTypeDefinition[] } = {
types: [
Expand All @@ -43,5 +44,6 @@ export const schema: { types: SchemaTypeDefinition[] } = {
defaultSeo,
brandAssets,
languageSettings,
richText,
],
};
14 changes: 11 additions & 3 deletions studio/schemas/objects/compensations/benefitsByLocation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineField } from "sanity";

import { companyLocationNameID } from "studio/schemas/documents/admin/companyLocation";
import { richText, title } from "studio/schemas/fields/text";
import { richTextID, title } from "studio/schemas/fields/text";
import { location, locationID } from "studio/schemas/objects/locations";

import {
Expand Down Expand Up @@ -60,7 +60,15 @@ export const benefitsByLocation = defineField({
name: "benefit",
type: "object",
title: "Benefit",
fields: [benefitType, title, richText],
fields: [
benefitType,
title,
{
name: richTextID,
title: "Body",
type: "internationalizedArrayRichText",
},
],
preview: {
select: {
title: title.name,
Expand Down Expand Up @@ -98,7 +106,7 @@ export const benefitsByLocation = defineField({
validation: (rule) =>
rule.custom((benefitsByLocation) => {
const isNotDuplicate: boolean = checkForDuplicateLocations(
benefitsByLocation as DocumentWithLocation[] | undefined,
benefitsByLocation as DocumentWithLocation[] | undefined
);
return (
isNotDuplicate ||
Expand Down
2 changes: 1 addition & 1 deletion studio/studioConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const config: WorkspaceOptions = {
languages: (client) => {
return client.fetch(SUPPORTED_LANGUAGES_QUERY);
},
fieldTypes: ["string"],
fieldTypes: ["string", "richText"],
}),
presentationTool({
previewUrl: {
Expand Down

0 comments on commit 36a46e8

Please sign in to comment.