diff --git a/src/collections/ChronologyEvents/endpoints/getAllEndpoint.ts b/src/collections/ChronologyEvents/endpoints/getAllEndpoint.ts index 064de8a..696defb 100644 --- a/src/collections/ChronologyEvents/endpoints/getAllEndpoint.ts +++ b/src/collections/ChronologyEvents/endpoints/getAllEndpoint.ts @@ -109,8 +109,10 @@ const handleSources = ( case "urlBlock": return { type: "url", - url: source.url, - label: getDomainFromUrl(source.url), + value: { + url: source.url, + label: getDomainFromUrl(source.url), + }, }; } }) ?? [] diff --git a/src/collections/Pages/Pages.ts b/src/collections/Pages/Pages.ts index de33984..192abc5 100644 --- a/src/collections/Pages/Pages.ts +++ b/src/collections/Pages/Pages.ts @@ -29,8 +29,7 @@ const fields = { summary: "summary", content: "content", credits: "credits", - collectibles: "collectibles", - folders: "folders", + sourceUrls: "sourceUrls", } as const satisfies Record; export const Pages = buildVersionedCollectionConfig({ @@ -42,13 +41,7 @@ export const Pages = buildVersionedCollectionConfig({ defaultSort: fields.slug, admin: { useAsTitle: fields.slug, - defaultColumns: [ - fields.slug, - fields.thumbnail, - fields.backgroundImage, - fields.translations, - fields.folders, - ], + defaultColumns: [fields.slug, fields.thumbnail, fields.backgroundImage, fields.translations], group: CollectionGroups.Collections, preview: ({ slug }) => `${process.env.PAYLOAD_PUBLIC_FRONTEND_BASE_URL}/en/pages/${slug}`, components: { @@ -121,6 +114,17 @@ export const Pages = buildVersionedCollectionConfig({ }), }, creditsField({ name: fields.credits }), + { + name: fields.sourceUrls, + label: "Source URLs", + type: "text", + hasMany: true, + admin: { + description: + "If the content originates from an external source (e.g: fandom.com, an online interview...) you can add a link to the original page(s) here", + width: "50%", + }, + }, ], }), ], diff --git a/src/collections/Pages/endpoints/getBySlugEndpoint.ts b/src/collections/Pages/endpoints/getBySlugEndpoint.ts index 747444d..d9c8ab8 100644 --- a/src/collections/Pages/endpoints/getBySlugEndpoint.ts +++ b/src/collections/Pages/endpoints/getBySlugEndpoint.ts @@ -20,6 +20,7 @@ import { convertImageToEndpointPayloadImage, convertRTCToEndpointRTC, convertRelationshipsToEndpointRelations, + getDomainFromUrl, } from "../../../utils/endpoints"; import { convertRecorderToEndpointRecorderPreview } from "../../Recorders/endpoints/getByID"; @@ -59,7 +60,17 @@ const convertPageToEndpointPage = async (page: Page): Promise => { ? { backgroundImage: convertImageToEndpointPayloadImage(backgroundImage) } : {}), translations: translations.map( - ({ content, language, sourceLanguage, title, pretitle, subtitle, summary, credits }) => ({ + ({ + content, + language, + sourceLanguage, + title, + pretitle, + subtitle, + summary, + credits, + sourceUrls, + }) => ({ language: isPayloadType(language) ? language.id : language, sourceLanguage: isPayloadType(sourceLanguage) ? sourceLanguage.id : sourceLanguage, ...(isNotEmpty(pretitle) ? { pretitle } : {}), @@ -69,6 +80,11 @@ const convertPageToEndpointPage = async (page: Page): Promise => { content: convertRTCToEndpointRTC(content), toc: handleToc(content), credits: convertCreditsToEndpointCredits(credits), + sourceUrls: + sourceUrls?.map((url) => ({ + url, + label: getDomainFromUrl(url), + })) ?? [], }) ), createdAt, diff --git a/src/shared b/src/shared index 63d1733..c2702ea 160000 --- a/src/shared +++ b/src/shared @@ -1 +1 @@ -Subproject commit 63d17331a17a5ab7874599d1df4ecf6b45ac89f3 +Subproject commit c2702ea508dde59264ee66100054bacc0834c029 diff --git a/src/types/collections.ts b/src/types/collections.ts index 4222a25..c3ab6e6 100644 --- a/src/types/collections.ts +++ b/src/types/collections.ts @@ -95,6 +95,7 @@ export interface Page { [k: string]: unknown; }; credits?: Credits; + sourceUrls?: string[] | null; id?: string | null; }[]; updatedBy: string | Recorder;