mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -0,0 +1,31 @@
|
||||
// models/advertisements/advertisements.placements.js
|
||||
//
|
||||
// Declarative registry of every ad placement in the client app. Each entry
|
||||
// is a self-contained "slot" — a page + position pair — that determines the
|
||||
// visual format (hero/banner/popup/sidebar) automatically. Adding a new
|
||||
// placement should only ever require adding one entry here (and wiring the
|
||||
// corresponding client page to fetch/render it) — nothing else in this file
|
||||
// should need to change.
|
||||
//
|
||||
// `key` is what's stored on advertisements.placement. `format` is what gets
|
||||
// denormalized onto advertisements.type on write (see applyAdvertisementFields
|
||||
// in controllers/admin/advertisements.controller.js) — type is never accepted
|
||||
// from the client once a placement is set.
|
||||
|
||||
const PLACEMENTS = [
|
||||
{ key: "dashboard.hero", format: "hero", page: "dashboard", pageLabel: "Dashboard", slotLabel: "Hero (top of page)" },
|
||||
{ key: "dashboard.popup", format: "popup", page: "dashboard", pageLabel: "Dashboard", slotLabel: "Popup (on load)" },
|
||||
{ key: "course_list.banner", format: "banner", page: "course_list", pageLabel: "Courses", slotLabel: "Banner (above course grid)" },
|
||||
{ key: "course_details.banner", format: "banner", page: "course_details", pageLabel: "Course Details", slotLabel: "Banner (below hero)" },
|
||||
{ key: "course_details.sidebar", format: "sidebar", page: "course_details", pageLabel: "Course Details", slotLabel: "Sidebar (beside course content)" },
|
||||
{ key: "plans.banner", format: "banner", page: "plans", pageLabel: "Plans", slotLabel: "Banner (above plan cards)" },
|
||||
];
|
||||
|
||||
const PLACEMENT_MAP = Object.fromEntries(PLACEMENTS.map((p) => [p.key, p]));
|
||||
const PLACEMENT_KEYS = PLACEMENTS.map((p) => p.key);
|
||||
|
||||
function getFormatForPlacement(key) {
|
||||
return PLACEMENT_MAP[key]?.format ?? null;
|
||||
}
|
||||
|
||||
module.exports = { PLACEMENTS, PLACEMENT_MAP, PLACEMENT_KEYS, getFormatForPlacement };
|
||||
Reference in New Issue
Block a user