From d4dc7ca9101e8782e0ca172adb8b7d76aa48617e Mon Sep 17 00:00:00 2001 From: DrMint <29893320+DrMint@users.noreply.github.com> Date: Sat, 11 May 2024 01:45:17 +0200 Subject: [PATCH] Added pretitle and subtitle to media --- src/collections/Audios/Audios.ts | 8 +++++++- src/collections/Audios/endpoints/getByID.ts | 4 +++- src/collections/Images/Images.ts | 9 ++++++++- src/collections/Images/endpoints/getByID.ts | 4 +++- src/collections/Videos/Videos.ts | 8 +++++++- src/collections/Videos/endpoints/getByID.ts | 4 +++- src/sdk.ts | 2 ++ src/types/collections.ts | 6 ++++++ 8 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/collections/Audios/Audios.ts b/src/collections/Audios/Audios.ts index 9e6a5e8..0da2804 100644 --- a/src/collections/Audios/Audios.ts +++ b/src/collections/Audios/Audios.ts @@ -14,7 +14,9 @@ const fields = { filesize: "filesize", updatedAt: "updatedAt", translations: "translations", + translationsPretitle: "pretitle", translationsTitle: "title", + translationsSubtitle: "subtitle", translationsDescription: "description", thumbnail: "thumbnail", duration: "duration", @@ -57,7 +59,11 @@ export const Audios = buildCollectionConfig({ required: true, minRows: 1, fields: [ - { name: fields.translationsTitle, type: "text", required: true }, + rowField([ + { name: fields.translationsPretitle, type: "text" }, + { name: fields.translationsTitle, type: "text", required: true }, + { name: fields.translationsSubtitle, type: "text" }, + ]), { name: fields.translationsDescription, type: "richText", diff --git a/src/collections/Audios/endpoints/getByID.ts b/src/collections/Audios/endpoints/getByID.ts index 5d49c27..2a3a8f9 100644 --- a/src/collections/Audios/endpoints/getByID.ts +++ b/src/collections/Audios/endpoints/getByID.ts @@ -69,9 +69,11 @@ export const convertAudioToEndpointAudio = ({ mimeType, updatedAt, translations: - translations?.map(({ language, title, description }) => ({ + translations?.map(({ language, title, pretitle, subtitle, description }) => ({ language: getLanguageId(language), + ...(isNotEmpty(pretitle) ? { pretitle } : {}), title, + ...(isNotEmpty(subtitle) ? { subtitle } : {}), ...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}), })) ?? [], duration, diff --git a/src/collections/Images/Images.ts b/src/collections/Images/Images.ts index 10b1935..25bfc6e 100644 --- a/src/collections/Images/Images.ts +++ b/src/collections/Images/Images.ts @@ -1,5 +1,6 @@ import { Collections } from "../../constants"; import { creditsField } from "../../fields/creditsField/creditsField"; +import { rowField } from "../../fields/rowField/rowField"; import { tagsField } from "../../fields/tagsField/tagsField"; import { translatedFields } from "../../fields/translatedFields/translatedFields"; import { createEditor } from "../../utils/editor"; @@ -13,7 +14,9 @@ const fields = { posts: "posts", updatedAt: "updatedAt", translations: "translations", + translationsPretitle: "pretitle", translationsTitle: "title", + translationsSubtitle: "subtitle", translationsDescription: "description", tags: "tags", credits: "credits", @@ -48,7 +51,11 @@ export const Images = buildImageCollectionConfig({ name: fields.translations, admin: { useAsTitle: fields.translationsTitle }, fields: [ - { name: fields.translationsTitle, type: "text", required: true }, + rowField([ + { name: fields.translationsPretitle, type: "text" }, + { name: fields.translationsTitle, type: "text", required: true }, + { name: fields.translationsSubtitle, type: "text" }, + ]), { name: fields.translationsDescription, type: "richText", diff --git a/src/collections/Images/endpoints/getByID.ts b/src/collections/Images/endpoints/getByID.ts index f320c09..740d163 100644 --- a/src/collections/Images/endpoints/getByID.ts +++ b/src/collections/Images/endpoints/getByID.ts @@ -71,9 +71,11 @@ export const convertImageToEndpointImage = ({ mimeType, updatedAt, translations: - translations?.map(({ language, title, description }) => ({ + translations?.map(({ language, title, pretitle, subtitle, description }) => ({ language: getLanguageId(language), + ...(isNotEmpty(pretitle) ? { pretitle } : {}), title, + ...(isNotEmpty(subtitle) ? { subtitle } : {}), ...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}), })) ?? [], credits: convertCreditsToEndpointCredits(credits), diff --git a/src/collections/Videos/Videos.ts b/src/collections/Videos/Videos.ts index 53c8c4e..e24574f 100644 --- a/src/collections/Videos/Videos.ts +++ b/src/collections/Videos/Videos.ts @@ -15,7 +15,9 @@ const fields = { filesize: "filesize", updatedAt: "updatedAt", translations: "translations", + translationsPretitle: "pretitle", translationsTitle: "title", + translationsSubtitle: "subtitle", translationsDescription: "description", translationsSubfile: "subfile", thumbnail: "thumbnail", @@ -66,7 +68,11 @@ export const Videos = buildCollectionConfig({ required: true, minRows: 1, fields: [ - { name: fields.translationsTitle, type: "text", required: true }, + rowField([ + { name: fields.translationsPretitle, type: "text" }, + { name: fields.translationsTitle, type: "text", required: true }, + { name: fields.translationsSubtitle, type: "text" }, + ]), { name: fields.translationsDescription, type: "richText", diff --git a/src/collections/Videos/endpoints/getByID.ts b/src/collections/Videos/endpoints/getByID.ts index b5239e6..6ff039e 100644 --- a/src/collections/Videos/endpoints/getByID.ts +++ b/src/collections/Videos/endpoints/getByID.ts @@ -79,9 +79,11 @@ export const convertVideoToEndpointVideo = ({ mimeType, updatedAt, translations: - translations?.map(({ language, title, description }) => ({ + translations?.map(({ language, title, pretitle, subtitle, description }) => ({ language: getLanguageId(language), + ...(isNotEmpty(pretitle) ? { pretitle } : {}), title, + ...(isNotEmpty(subtitle) ? { subtitle } : {}), ...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}), })) ?? [], diff --git a/src/sdk.ts b/src/sdk.ts index ed7a6e1..1d7bf55 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -450,7 +450,9 @@ export type EndpointMedia = { tagGroups: EndpointTagsGroup[]; translations: { language: string; + pretitle?: string; title: string; + subtitle?: string; description?: RichTextContent; }[]; credits: EndpointCredit[]; diff --git a/src/types/collections.ts b/src/types/collections.ts index bea7f43..d5dfd8a 100644 --- a/src/types/collections.ts +++ b/src/types/collections.ts @@ -111,7 +111,9 @@ export interface Image { translations?: | { language: string | Language; + pretitle?: string | null; title: string; + subtitle?: string | null; description?: { root: { type: string; @@ -559,7 +561,9 @@ export interface Audio { thumbnail?: string | MediaThumbnail | null; translations: { language: string | Language; + pretitle?: string | null; title: string; + subtitle?: string | null; description?: { root: { type: string; @@ -631,7 +635,9 @@ export interface Video { thumbnail?: string | MediaThumbnail | null; translations: { language: string | Language; + pretitle?: string | null; title: string; + subtitle?: string | null; description?: { root: { type: string;