Dokumenty - wyrównywanie tytułow.

This commit is contained in:
dm
2025-12-20 13:53:20 +01:00
parent 8ef6ebd1b1
commit e76cd1788c
4 changed files with 82 additions and 39 deletions

View File

@@ -5,12 +5,10 @@ import fs from "node:fs";
import Markdown from "../../islands/Markdown.jsx";
import "../../styles/document.css";
/* ===== Typy ===== */
type DocFile = {
nazwa?: string;
file?: string; // pdf
slug?: string; // yaml / czytaj
file?: string;
slug?: string;
};
type DocGroup = {
@@ -24,8 +22,6 @@ type DocsYaml = {
grupy?: Record<string, DocGroup>;
};
/* ===== Load YAML ===== */
const doc = yaml.load(
fs.readFileSync("./src/content/document/documents.yaml", "utf8"),
) as DocsYaml;
@@ -37,8 +33,6 @@ const groups = doc?.grupy ?? {};
const left = groups["otworz"] ?? {};
const right = groups["pobierz"] ?? {};
/* ===== Helpers ===== */
function normalizePublicHref(input?: string) {
let s = String(input ?? "").trim();
if (!s) return "";
@@ -49,13 +43,11 @@ function normalizePublicHref(input?: string) {
---
<DefaultLayout title={pageTitle} description={pageDesc}>
{/* CONTENT */}
<section class="f-section">
<div class="f-section-grid md:grid-cols-2 gap-10 items-start">
<div class="f-section-grid-top md:grid-cols-2 gap-10">
{/* ===== LEWA — CZYTAJ ===== */}
<div>
<h3 class="f-section-title">{left.tytul ?? "Przeczytaj"}</h3>
<h3 class="f-section-title mt-0">{left.tytul ?? "Przeczytaj"}</h3>
{!left.pliki?.length ? (
<p class="opacity-70 mt-4">Brak dokumentów.</p>
@@ -68,9 +60,7 @@ function normalizePublicHref(input?: string) {
href={`/dokumenty/${p.slug}`}
title={p.nazwa}
>
{/* <div class="f-document-icon">📖</div> */}
<div class="f-document-title">{p.nazwa}</div>
{/* <div class="f-document-meta">Otwórz</div> */}
</a>
) : null
))}
@@ -79,7 +69,7 @@ function normalizePublicHref(input?: string) {
</div>
<div>
<h3 class="f-section-title">{right.tytul ?? "Pobierz"}</h3>
<h3 class="f-section-title mt-0">{right.tytul ?? "Pobierz"}</h3>
{!right.pliki?.length ? (
<p class="opacity-70 mt-4">Brak plików.</p>

View File

@@ -10,8 +10,19 @@ import { loadYamlFile } from "../../lib/loadYaml";
type SeoYaml = any;
type InternetParam = { klucz: string; label: string; value: string | number };
type InternetCena = { budynek: number | string; umowa: number | string; miesiecznie: number; aktywacja?: number };
type InternetCard = { nazwa: string; widoczny?: boolean; popularny?: boolean; parametry?: InternetParam[]; ceny?: InternetCena[] };
type InternetCena = {
budynek: number | string;
umowa: number | string;
miesiecznie: number;
aktywacja?: number;
};
type InternetCard = {
nazwa: string;
widoczny?: boolean;
popularny?: boolean;
parametry?: InternetParam[];
ceny?: InternetCena[];
};
type InternetCardsYaml = {
tytul?: string;
opis?: string;
@@ -22,18 +33,46 @@ type InternetCardsYaml = {
};
type PhoneParam = { klucz: string; label: string; value: string | number };
type PhoneCard = { nazwa: string; widoczny?: boolean; popularny?: boolean; cena?: { wartosc: number; opis?: string }; parametry?: PhoneParam[] };
type PhoneCard = {
nazwa: string;
widoczny?: boolean;
popularny?: boolean;
cena?: { wartosc: number; opis?: string };
parametry?: PhoneParam[];
};
type PhoneCardsYaml = { cards?: PhoneCard[] };
type Addon = { id: string; nazwa: string; typ?: string; ilosc?: boolean; min?: number; max?: number; krok?: number; opis?: string; cena: number };
type Addon = {
id: string;
nazwa: string;
typ?: string;
ilosc?: boolean;
min?: number;
max?: number;
krok?: number;
opis?: string;
cena: number;
};
type AddonsYaml = { cena_opis?: string; dodatki?: Addon[] };
const seo = loadYamlFile<SeoYaml>(
path.join(process.cwd(), "src", "content", "internet-swiatlowodowy", "seo.yaml"),
path.join(
process.cwd(),
"src",
"content",
"internet-swiatlowodowy",
"seo.yaml",
),
);
const data = loadYamlFile<InternetCardsYaml>(
path.join(process.cwd(), "src", "content", "internet-swiatlowodowy", "cards.yaml"),
path.join(
process.cwd(),
"src",
"content",
"internet-swiatlowodowy",
"cards.yaml",
),
);
const phoneData = loadYamlFile<PhoneCardsYaml>(
@@ -41,7 +80,13 @@ const phoneData = loadYamlFile<PhoneCardsYaml>(
);
const addonsData = loadYamlFile<AddonsYaml>(
path.join(process.cwd(), "src", "content", "internet-swiatlowodowy", "addons.yaml"),
path.join(
process.cwd(),
"src",
"content",
"internet-swiatlowodowy",
"addons.yaml",
),
);
const tytul = data?.tytul ?? "";
@@ -51,17 +96,21 @@ const uwaga = data?.uwaga ?? "";
const waluta = data?.waluta ?? "PLN";
const cenaOpis = data?.cena_opis ?? "zł/mies.";
const cards = (Array.isArray(data?.cards)
? data.cards.filter((c) => c?.widoczny === true)
: []) as InternetCard[];
const cards = (
Array.isArray(data?.cards)
? data.cards.filter((c) => c?.widoczny === true)
: []
) as InternetCard[];
const phoneCards = (Array.isArray(phoneData?.cards)
? phoneData.cards.filter((c) => c?.widoczny === true)
: []) as PhoneCard[];
const phoneCards = (
Array.isArray(phoneData?.cards)
? phoneData.cards.filter((c) => c?.widoczny === true)
: []
) as PhoneCard[];
const addons = (Array.isArray(addonsData?.dodatki)
? addonsData.dodatki
: []) as Addon[];
const addons = (
Array.isArray(addonsData?.dodatki) ? addonsData.dodatki : []
) as Addon[];
const addonsCenaOpis = addonsData?.cena_opis ?? cenaOpis;
@@ -79,9 +128,9 @@ const switchesData = loadYamlFile<SwitchesYaml>(
path.join(process.cwd(), "src", "content", "site", "switches.yaml"),
);
const switches = (Array.isArray(switchesData?.switches)
? switchesData.switches
: []) as SwitchDef[];
const switches = (
Array.isArray(switchesData?.switches) ? switchesData.switches : []
) as SwitchDef[];
---
<DefaultLayout seo={seo}>
@@ -100,8 +149,8 @@ const switches = (Array.isArray(switchesData?.switches)
addonsCenaOpis={addonsCenaOpis}
switches={switches}
/>
<p><span class="f-card-price text-sm">* </span>{uwaga}</p>
</div>
<p><span class="f-card-price text-sm">* </span>{uwaga}</p>
</section>
<SectionRenderer src="./src/content/internet-swiatlowodowy/section.yaml" />

View File

@@ -1,6 +1,6 @@
.f-offers {
/* .f-offers {
@apply my-6;
}
} */
.f-offers-grid {
@apply flex flex-wrap justify-center gap-8;

View File

@@ -13,6 +13,10 @@
@apply f-section text-center;
}
.f-section-grid-top {
@apply grid gap-5 max-w-7xl mx-auto mt-8;
}
.f-section-grid {
@apply grid items-center gap-5 max-w-7xl mx-auto mt-8;
}