Premium szczegóły zmiana sekcji
This commit is contained in:
@@ -6,7 +6,6 @@ import Markdown from "../../islands/Markdown.jsx";
|
|||||||
import AddonChannelsGrid from "../../islands/jambox/AddonChannelsModal.jsx";
|
import AddonChannelsGrid from "../../islands/jambox/AddonChannelsModal.jsx";
|
||||||
import "../../styles/jambox-tematyczne.css";
|
import "../../styles/jambox-tematyczne.css";
|
||||||
|
|
||||||
/** Typy minimalne */
|
|
||||||
type AddonPriceRow = {
|
type AddonPriceRow = {
|
||||||
pakiety?: string[] | any;
|
pakiety?: string[] | any;
|
||||||
"12m"?: number | string;
|
"12m"?: number | string;
|
||||||
@@ -25,7 +24,6 @@ type TvAddon = {
|
|||||||
group_mode?: string;
|
group_mode?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ✅ OPCJA A: metadane grupy + CTA
|
|
||||||
type GroupCta = {
|
type GroupCta = {
|
||||||
label?: string;
|
label?: string;
|
||||||
href?: string;
|
href?: string;
|
||||||
@@ -41,7 +39,6 @@ type GroupMeta = {
|
|||||||
type TvAddonsDoc = {
|
type TvAddonsDoc = {
|
||||||
tytul?: string;
|
tytul?: string;
|
||||||
opis?: string;
|
opis?: string;
|
||||||
cena_opis?: string;
|
|
||||||
dodatki?: TvAddon[];
|
dodatki?: TvAddon[];
|
||||||
grupy?: Record<string, GroupMeta>;
|
grupy?: Record<string, GroupMeta>;
|
||||||
};
|
};
|
||||||
@@ -50,81 +47,48 @@ const doc = yaml.load(
|
|||||||
fs.readFileSync("./src/content/internet-telewizja/tv-addons.yaml", "utf8"),
|
fs.readFileSync("./src/content/internet-telewizja/tv-addons.yaml", "utf8"),
|
||||||
) as TvAddonsDoc;
|
) as TvAddonsDoc;
|
||||||
|
|
||||||
const pageTitle = doc?.tytul ?? "Dodatkowe pakiety TV";
|
const addons = Array.isArray(doc?.dodatki) ? doc.dodatki : [];
|
||||||
const pageDesc = doc?.opis ?? "";
|
const groupMeta = doc?.grupy ?? {};
|
||||||
const addons: TvAddon[] = Array.isArray(doc?.dodatki) ? doc.dodatki : [];
|
|
||||||
|
|
||||||
// ✅ mapa meta grup
|
const tid = Number(Astro.params.tid);
|
||||||
const groupMeta: Record<string, GroupMeta> = doc?.grupy ?? {};
|
const picked = addons.find((a) => Number(a?.tid) === tid);
|
||||||
|
|
||||||
// --- dynamic param ---
|
|
||||||
const tidParam = Astro.params.tid; // np. "49"
|
|
||||||
const tid = Number(tidParam);
|
|
||||||
|
|
||||||
const picked =
|
|
||||||
Number.isFinite(tid)
|
|
||||||
? addons.find((a) => Number(a?.tid) === tid)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
if (!picked) {
|
if (!picked) {
|
||||||
return new Response("Nie znaleziono pakietu dla podanego tid.", { status: 404 });
|
return new Response("Nie znaleziono pakietu.", { status: 404 });
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- jeśli jest group => bierzemy całą grupę ---
|
|
||||||
const pickedGroup = String(picked?.group ?? "").trim();
|
const pickedGroup = String(picked?.group ?? "").trim();
|
||||||
|
|
||||||
let viewAddons: TvAddon[] = [];
|
const viewAddons = pickedGroup
|
||||||
if (pickedGroup) {
|
? addons.filter((a) => String(a?.group ?? "").trim() === pickedGroup)
|
||||||
viewAddons = addons.filter((a) => String(a?.group ?? "").trim() === pickedGroup);
|
: [picked];
|
||||||
} else {
|
|
||||||
viewAddons = [picked];
|
|
||||||
}
|
|
||||||
|
|
||||||
// (jak miałeś) sortowanie w grupie — możesz zostawić albo wywalić
|
const footerCta =
|
||||||
viewAddons = viewAddons
|
|
||||||
.slice()
|
|
||||||
.sort((a, b) => Number(a?.tid ?? 0) - Number(b?.tid ?? 0));
|
|
||||||
|
|
||||||
// tytuł/description strony
|
|
||||||
const singleTitle = pickedGroup
|
|
||||||
? (groupMeta[pickedGroup]?.tytul ?? pickedGroup.toUpperCase() ?? pageTitle)
|
|
||||||
: (String(picked?.nazwa ?? "").trim() || pageTitle);
|
|
||||||
|
|
||||||
const singleDesc = pageDesc;
|
|
||||||
|
|
||||||
// ✅ CTA dla tej grupy (jeśli istnieje)
|
|
||||||
const footerCta: GroupCta | undefined =
|
|
||||||
pickedGroup ? groupMeta[pickedGroup]?.rejestracja : undefined;
|
pickedGroup ? groupMeta[pickedGroup]?.rejestracja : undefined;
|
||||||
---
|
---
|
||||||
|
|
||||||
<DefaultLayout title={singleTitle} description={singleDesc}>
|
<DefaultLayout
|
||||||
{/* Opcjonalnie: box jak na stronie ogólnej, tylko jeśli jesteśmy w grupie */}
|
title={picked?.nazwa ?? doc?.tytul}
|
||||||
<div class={pickedGroup ? "f-addon-group" : ""}>
|
description={doc?.opis}
|
||||||
|
>
|
||||||
{
|
{
|
||||||
viewAddons.map((addon: TvAddon, index: number) => {
|
viewAddons.map((addon, index) => {
|
||||||
const isAboveFold = index === 0;
|
|
||||||
|
|
||||||
const pkgName = String(addon?.nazwa ?? "").trim();
|
const pkgName = String(addon?.nazwa ?? "").trim();
|
||||||
const hasYamlImage = !!String(addon?.image ?? "").trim();
|
const hasYamlImage = !!String(addon?.image ?? "").trim();
|
||||||
const assumeHasMedia = pkgName ? true : hasYamlImage;
|
const assumeHasMedia = pkgName || hasYamlImage;
|
||||||
|
const isAboveFold = index === 0;
|
||||||
const anchorId = addon?.tid != null ? `tid-${addon.tid}` : undefined;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section class="f-section" id={anchorId}>
|
<section class="f-section" id={`tid-${addon.tid}`}>
|
||||||
<div
|
<div
|
||||||
class={`f-section-grid f-addon-grid f-addon-section ${
|
class={`f-section-grid f-addon-section ${
|
||||||
assumeHasMedia ? "md:grid-cols-2" : "md:grid-cols-1"
|
assumeHasMedia ? "md:grid-cols-2" : "md:grid-cols-1"
|
||||||
}`}
|
}`}
|
||||||
data-addon-section
|
data-addon-section
|
||||||
data-has-media={assumeHasMedia ? "1" : "0"}
|
data-has-media={assumeHasMedia ? "1" : "0"}
|
||||||
>
|
>
|
||||||
<div class="f-addon-text">
|
{/* MEDIA — odpowiednik <Image /> */}
|
||||||
{pkgName && <h2 class="f-section-title">{pkgName}</h2>}
|
<div class="f-addon-media md:order-2">
|
||||||
{addon?.opis && <Markdown text={addon.opis} />}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="f-addon-media">
|
|
||||||
{pkgName ? (
|
{pkgName ? (
|
||||||
<AddonChannelsGrid
|
<AddonChannelsGrid
|
||||||
client:idle
|
client:idle
|
||||||
@@ -135,28 +99,34 @@ const footerCta: GroupCta | undefined =
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* TEKST */}
|
||||||
|
<div class="md:order-1">
|
||||||
|
{pkgName && <h2 class="f-section-title">{pkgName}</h2>}
|
||||||
|
{addon?.opis && <Markdown text={addon.opis} />}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
{/* ✅ STOPKA GRUPY: tylko na stronach grupowych */}
|
{footerCta?.href && footerCta?.label ? (
|
||||||
{pickedGroup && footerCta?.href && footerCta?.label ? (
|
<section class="f-section">
|
||||||
<div class="f-addon-group-footer fuz-markdown max-w-none">
|
<div class="f-section-grid md:grid-cols-1">
|
||||||
{footerCta.opis ? <p>{footerCta.opis}</p> : null}
|
<div class="fuz-markdown max-w-none">
|
||||||
|
{footerCta.opis && <p>{footerCta.opis}</p>}
|
||||||
|
<div class="f-section-nav">
|
||||||
<a
|
<a
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
href={footerCta.href}
|
href={footerCta.href}
|
||||||
title={footerCta.title ?? footerCta.label}
|
title={footerCta.title ?? footerCta.label}
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
>
|
||||||
{footerCta.label}
|
{footerCta.label}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
) : null}
|
||||||
</DefaultLayout>
|
</DefaultLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user