Added pretitle and subtitle to media

This commit is contained in:
DrMint 2024-05-11 01:45:17 +02:00
parent ff9c1926d5
commit d4dc7ca910
8 changed files with 39 additions and 6 deletions

View File

@ -14,7 +14,9 @@ const fields = {
filesize: "filesize", filesize: "filesize",
updatedAt: "updatedAt", updatedAt: "updatedAt",
translations: "translations", translations: "translations",
translationsPretitle: "pretitle",
translationsTitle: "title", translationsTitle: "title",
translationsSubtitle: "subtitle",
translationsDescription: "description", translationsDescription: "description",
thumbnail: "thumbnail", thumbnail: "thumbnail",
duration: "duration", duration: "duration",
@ -57,7 +59,11 @@ export const Audios = buildCollectionConfig({
required: true, required: true,
minRows: 1, minRows: 1,
fields: [ 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, name: fields.translationsDescription,
type: "richText", type: "richText",

View File

@ -69,9 +69,11 @@ export const convertAudioToEndpointAudio = ({
mimeType, mimeType,
updatedAt, updatedAt,
translations: translations:
translations?.map(({ language, title, description }) => ({ translations?.map(({ language, title, pretitle, subtitle, description }) => ({
language: getLanguageId(language), language: getLanguageId(language),
...(isNotEmpty(pretitle) ? { pretitle } : {}),
title, title,
...(isNotEmpty(subtitle) ? { subtitle } : {}),
...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}), ...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}),
})) ?? [], })) ?? [],
duration, duration,

View File

@ -1,5 +1,6 @@
import { Collections } from "../../constants"; import { Collections } from "../../constants";
import { creditsField } from "../../fields/creditsField/creditsField"; import { creditsField } from "../../fields/creditsField/creditsField";
import { rowField } from "../../fields/rowField/rowField";
import { tagsField } from "../../fields/tagsField/tagsField"; import { tagsField } from "../../fields/tagsField/tagsField";
import { translatedFields } from "../../fields/translatedFields/translatedFields"; import { translatedFields } from "../../fields/translatedFields/translatedFields";
import { createEditor } from "../../utils/editor"; import { createEditor } from "../../utils/editor";
@ -13,7 +14,9 @@ const fields = {
posts: "posts", posts: "posts",
updatedAt: "updatedAt", updatedAt: "updatedAt",
translations: "translations", translations: "translations",
translationsPretitle: "pretitle",
translationsTitle: "title", translationsTitle: "title",
translationsSubtitle: "subtitle",
translationsDescription: "description", translationsDescription: "description",
tags: "tags", tags: "tags",
credits: "credits", credits: "credits",
@ -48,7 +51,11 @@ export const Images = buildImageCollectionConfig({
name: fields.translations, name: fields.translations,
admin: { useAsTitle: fields.translationsTitle }, admin: { useAsTitle: fields.translationsTitle },
fields: [ 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, name: fields.translationsDescription,
type: "richText", type: "richText",

View File

@ -71,9 +71,11 @@ export const convertImageToEndpointImage = ({
mimeType, mimeType,
updatedAt, updatedAt,
translations: translations:
translations?.map(({ language, title, description }) => ({ translations?.map(({ language, title, pretitle, subtitle, description }) => ({
language: getLanguageId(language), language: getLanguageId(language),
...(isNotEmpty(pretitle) ? { pretitle } : {}),
title, title,
...(isNotEmpty(subtitle) ? { subtitle } : {}),
...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}), ...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}),
})) ?? [], })) ?? [],
credits: convertCreditsToEndpointCredits(credits), credits: convertCreditsToEndpointCredits(credits),

View File

@ -15,7 +15,9 @@ const fields = {
filesize: "filesize", filesize: "filesize",
updatedAt: "updatedAt", updatedAt: "updatedAt",
translations: "translations", translations: "translations",
translationsPretitle: "pretitle",
translationsTitle: "title", translationsTitle: "title",
translationsSubtitle: "subtitle",
translationsDescription: "description", translationsDescription: "description",
translationsSubfile: "subfile", translationsSubfile: "subfile",
thumbnail: "thumbnail", thumbnail: "thumbnail",
@ -66,7 +68,11 @@ export const Videos = buildCollectionConfig({
required: true, required: true,
minRows: 1, minRows: 1,
fields: [ 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, name: fields.translationsDescription,
type: "richText", type: "richText",

View File

@ -79,9 +79,11 @@ export const convertVideoToEndpointVideo = ({
mimeType, mimeType,
updatedAt, updatedAt,
translations: translations:
translations?.map(({ language, title, description }) => ({ translations?.map(({ language, title, pretitle, subtitle, description }) => ({
language: getLanguageId(language), language: getLanguageId(language),
...(isNotEmpty(pretitle) ? { pretitle } : {}),
title, title,
...(isNotEmpty(subtitle) ? { subtitle } : {}),
...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}), ...(isNotEmpty(description) ? { description: convertRTCToEndpointRTC(description) } : {}),
})) ?? [], })) ?? [],

View File

@ -450,7 +450,9 @@ export type EndpointMedia = {
tagGroups: EndpointTagsGroup[]; tagGroups: EndpointTagsGroup[];
translations: { translations: {
language: string; language: string;
pretitle?: string;
title: string; title: string;
subtitle?: string;
description?: RichTextContent; description?: RichTextContent;
}[]; }[];
credits: EndpointCredit[]; credits: EndpointCredit[];

View File

@ -111,7 +111,9 @@ export interface Image {
translations?: translations?:
| { | {
language: string | Language; language: string | Language;
pretitle?: string | null;
title: string; title: string;
subtitle?: string | null;
description?: { description?: {
root: { root: {
type: string; type: string;
@ -559,7 +561,9 @@ export interface Audio {
thumbnail?: string | MediaThumbnail | null; thumbnail?: string | MediaThumbnail | null;
translations: { translations: {
language: string | Language; language: string | Language;
pretitle?: string | null;
title: string; title: string;
subtitle?: string | null;
description?: { description?: {
root: { root: {
type: string; type: string;
@ -631,7 +635,9 @@ export interface Video {
thumbnail?: string | MediaThumbnail | null; thumbnail?: string | MediaThumbnail | null;
translations: { translations: {
language: string | Language; language: string | Language;
pretitle?: string | null;
title: string; title: string;
subtitle?: string | null;
description?: { description?: {
root: { root: {
type: string; type: string;