Added source urls to page

This commit is contained in:
DrMint 2024-08-16 14:52:00 +02:00
parent 5c059d0410
commit 0806c74f8c
5 changed files with 36 additions and 13 deletions

View File

@ -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),
},
};
}
}) ?? []

View File

@ -29,8 +29,7 @@ const fields = {
summary: "summary",
content: "content",
credits: "credits",
collectibles: "collectibles",
folders: "folders",
sourceUrls: "sourceUrls",
} as const satisfies Record<string, string>;
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%",
},
},
],
}),
],

View File

@ -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<EndpointPage> => {
? { 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<EndpointPage> => {
content: convertRTCToEndpointRTC(content),
toc: handleToc(content),
credits: convertCreditsToEndpointCredits(credits),
sourceUrls:
sourceUrls?.map((url) => ({
url,
label: getDomainFromUrl(url),
})) ?? [],
})
),
createdAt,

@ -1 +1 @@
Subproject commit 63d17331a17a5ab7874599d1df4ecf6b45ac89f3
Subproject commit c2702ea508dde59264ee66100054bacc0834c029

View File

@ -95,6 +95,7 @@ export interface Page {
[k: string]: unknown;
};
credits?: Credits;
sourceUrls?: string[] | null;
id?: string | null;
}[];
updatedBy: string | Recorder;