+
{events.map((event: EhkEvent) => {
- const descriptionData = event.description?.[`text_${lang}`];
- const images = event.images || [];
+ const coverImage =
+ typeof event.coverImage === "object" && event.coverImage !== null
+ ? (event.coverImage as Media)
+ : null;
- return (
-
-
-
-
- {event.title}
-
-
-
-
- {descriptionData ? (
-
-
-
- ) : null}
+ const description = event.description?.[`text_${lang}`] as
+ | SerializedEditorState
+ | null
+ | undefined;
- {images.length > 0 && (
-
- {images.map((imgObj, imgIdx) => {
- const coverImage = typeof imgObj.image === "object" && imgObj.image !== null ? (imgObj.image as Media) : null;
- if (!coverImage?.url) return null;
-
- return (
-
- {images.length === 1 ? (
- // eslint-disable-next-line @next/next/no-img-element
-

- ) : (
-
- )}
-
- );
- })}
-
- )}
+ const galleryImages = (event.gallery ?? [])
+ .map((item) =>
+ typeof item.image === "object" && item.image !== null
+ ? (item.image as Media)
+ : null
+ )
+ .filter((img): img is Media => img !== null && !!img.url);
- {event.links && event.links.length > 0 && (
-
-
-
- {lang === 'hu' ? 'További információk:' : 'More information:'}
-
-
-
- )}
-
-
+ const links = (event.links ?? []).map((link) => ({
+ label: link.label,
+ url: link.url,
+ }));
+
+ return (
+
);
})}
diff --git a/src/collections/EhkEvents.ts b/src/collections/EhkEvents.ts
index 942abcb..d5be7f8 100644
--- a/src/collections/EhkEvents.ts
+++ b/src/collections/EhkEvents.ts
@@ -51,11 +51,23 @@ export const EhkEvents: CollectionConfig = {
],
},
{
- name: 'images',
- label: 'Képek',
+ name: 'coverImage',
+ label: 'Borítókép',
+ type: 'upload',
+ relationTo: 'media',
+ required: false,
+ admin: {
+ description: 'A rendezvény kártyáján megjelenő nagy borítókép',
+ },
+ },
+ {
+ name: 'gallery',
+ label: 'Galéria',
type: 'array',
- required: true,
- minRows: 1,
+ required: false,
+ admin: {
+ description: 'Képek a galéria karuszelhez',
+ },
fields: [
{
name: 'image',
diff --git a/src/dictionaries/en/news.json b/src/dictionaries/en/news.json
index d5c1233..3386c85 100644
--- a/src/dictionaries/en/news.json
+++ b/src/dictionaries/en/news.json
@@ -29,7 +29,11 @@
"time": "TIME",
"location": "LOCATION",
"link": "LINK",
+ "links_label": "LINKS",
"description_label": "DESCRIPTION",
+ "gallery": "GALLERY",
+ "prev_image": "Previous image",
+ "next_image": "Next image",
"share": "Share",
"no_events": "No events scheduled for this week."
},
diff --git a/src/dictionaries/hu/news.json b/src/dictionaries/hu/news.json
index e81a208..f57917f 100644
--- a/src/dictionaries/hu/news.json
+++ b/src/dictionaries/hu/news.json
@@ -29,7 +29,11 @@
"time": "IDŐPONT",
"location": "HELYSZÍN",
"link": "LINK",
+ "links_label": "LINKEK",
"description_label": "LEÍRÁS",
+ "gallery": "GALÉRIA",
+ "prev_image": "Előző kép",
+ "next_image": "Következő kép",
"share": "Megosztás",
"no_events": "Nincsenek események ezen a héten."
},
diff --git a/src/migrations/20260701_000000_ehk_events_cover_and_gallery.ts b/src/migrations/20260701_000000_ehk_events_cover_and_gallery.ts
new file mode 100644
index 0000000..2358ab3
--- /dev/null
+++ b/src/migrations/20260701_000000_ehk_events_cover_and_gallery.ts
@@ -0,0 +1,29 @@
+import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
+
+export async function up({ db, payload, req }: MigrateUpArgs): Promise
{
+ await db.execute(sql`
+ ALTER TABLE "ehk_events_images" RENAME TO "ehk_events_gallery";
+ ALTER TABLE "ehk_events_gallery" RENAME CONSTRAINT "ehk_events_images_pkey" TO "ehk_events_gallery_pkey";
+ ALTER TABLE "ehk_events_gallery" RENAME CONSTRAINT "ehk_events_images_image_id_media_id_fk" TO "ehk_events_gallery_image_id_media_id_fk";
+ ALTER TABLE "ehk_events_gallery" RENAME CONSTRAINT "ehk_events_images_parent_id_fk" TO "ehk_events_gallery_parent_id_fk";
+ ALTER INDEX "ehk_events_images_order_idx" RENAME TO "ehk_events_gallery_order_idx";
+ ALTER INDEX "ehk_events_images_parent_id_idx" RENAME TO "ehk_events_gallery_parent_id_idx";
+ ALTER INDEX "ehk_events_images_image_idx" RENAME TO "ehk_events_gallery_image_idx";
+ ALTER TABLE "ehk_events" ADD COLUMN "cover_image_id" integer;
+ ALTER TABLE "ehk_events" ADD CONSTRAINT "ehk_events_cover_image_id_media_id_fk" FOREIGN KEY ("cover_image_id") REFERENCES "public"."media"("id") ON DELETE set null ON UPDATE no action;
+ CREATE INDEX "ehk_events_cover_image_idx" ON "ehk_events" USING btree ("cover_image_id");`)
+}
+
+export async function down({ db, payload, req }: MigrateDownArgs): Promise {
+ await db.execute(sql`
+ ALTER TABLE "ehk_events" DROP CONSTRAINT "ehk_events_cover_image_id_media_id_fk";
+ DROP INDEX "ehk_events_cover_image_idx";
+ ALTER TABLE "ehk_events" DROP COLUMN "cover_image_id";
+ ALTER INDEX "ehk_events_gallery_order_idx" RENAME TO "ehk_events_images_order_idx";
+ ALTER INDEX "ehk_events_gallery_parent_id_idx" RENAME TO "ehk_events_images_parent_id_idx";
+ ALTER INDEX "ehk_events_gallery_image_idx" RENAME TO "ehk_events_images_image_idx";
+ ALTER TABLE "ehk_events_gallery" RENAME CONSTRAINT "ehk_events_gallery_image_id_media_id_fk" TO "ehk_events_images_image_id_media_id_fk";
+ ALTER TABLE "ehk_events_gallery" RENAME CONSTRAINT "ehk_events_gallery_parent_id_fk" TO "ehk_events_images_parent_id_fk";
+ ALTER TABLE "ehk_events_gallery" RENAME CONSTRAINT "ehk_events_gallery_pkey" TO "ehk_events_images_pkey";
+ ALTER TABLE "ehk_events_gallery" RENAME TO "ehk_events_images";`)
+}
diff --git a/src/migrations/index.ts b/src/migrations/index.ts
index 567a50b..b99ebb3 100644
--- a/src/migrations/index.ts
+++ b/src/migrations/index.ts
@@ -26,6 +26,7 @@ import * as migration_20260619_141957_add_permissions_submission_and_external_li
import * as migration_20260619_173736_academic_scholarship_faq from './20260619_173736_academic_scholarship_faq';
import * as migration_20260620_123301 from './20260620_123301';
import * as migration_20260620_151905_ehk_scholarships from './20260620_151905_ehk_scholarships';
+import * as migration_20260701_000000_ehk_events_cover_and_gallery from './20260701_000000_ehk_events_cover_and_gallery';
export const migrations = [
{
@@ -168,4 +169,9 @@ export const migrations = [
down: migration_20260620_151905_ehk_scholarships.down,
name: '20260620_151905_ehk_scholarships',
},
+ {
+ up: migration_20260701_000000_ehk_events_cover_and_gallery.up,
+ down: migration_20260701_000000_ehk_events_cover_and_gallery.down,
+ name: '20260701_000000_ehk_events_cover_and_gallery',
+ },
];
diff --git a/src/payload-types.ts b/src/payload-types.ts
index 533e368..fae6ea9 100644
--- a/src/payload-types.ts
+++ b/src/payload-types.ts
@@ -613,10 +613,19 @@ export interface EhkEvent {
[k: string]: unknown;
};
};
- images: {
- image: number | Media;
- id?: string | null;
- }[];
+ /**
+ * A rendezvény kártyáján megjelenő nagy borítókép
+ */
+ coverImage?: (number | null) | Media;
+ /**
+ * Képek a galéria karuszelhez
+ */
+ gallery?:
+ | {
+ image: number | Media;
+ id?: string | null;
+ }[]
+ | null;
order?: number | null;
/**
* Eseményhez tartozó weboldal, Facebook, vagy más hivatkozások.
@@ -1255,7 +1264,8 @@ export interface EhkEventsSelect {
text_hu?: T;
text_en?: T;
};
- images?:
+ coverImage?: T;
+ gallery?:
| T
| {
image?: T;