Dokumenty - wyrównywanie tytułow.
This commit is contained in:
@@ -5,12 +5,10 @@ import fs from "node:fs";
|
|||||||
import Markdown from "../../islands/Markdown.jsx";
|
import Markdown from "../../islands/Markdown.jsx";
|
||||||
import "../../styles/document.css";
|
import "../../styles/document.css";
|
||||||
|
|
||||||
/* ===== Typy ===== */
|
|
||||||
|
|
||||||
type DocFile = {
|
type DocFile = {
|
||||||
nazwa?: string;
|
nazwa?: string;
|
||||||
file?: string; // pdf
|
file?: string;
|
||||||
slug?: string; // yaml / czytaj
|
slug?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DocGroup = {
|
type DocGroup = {
|
||||||
@@ -24,8 +22,6 @@ type DocsYaml = {
|
|||||||
grupy?: Record<string, DocGroup>;
|
grupy?: Record<string, DocGroup>;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ===== Load YAML ===== */
|
|
||||||
|
|
||||||
const doc = yaml.load(
|
const doc = yaml.load(
|
||||||
fs.readFileSync("./src/content/document/documents.yaml", "utf8"),
|
fs.readFileSync("./src/content/document/documents.yaml", "utf8"),
|
||||||
) as DocsYaml;
|
) as DocsYaml;
|
||||||
@@ -37,8 +33,6 @@ const groups = doc?.grupy ?? {};
|
|||||||
const left = groups["otworz"] ?? {};
|
const left = groups["otworz"] ?? {};
|
||||||
const right = groups["pobierz"] ?? {};
|
const right = groups["pobierz"] ?? {};
|
||||||
|
|
||||||
/* ===== Helpers ===== */
|
|
||||||
|
|
||||||
function normalizePublicHref(input?: string) {
|
function normalizePublicHref(input?: string) {
|
||||||
let s = String(input ?? "").trim();
|
let s = String(input ?? "").trim();
|
||||||
if (!s) return "";
|
if (!s) return "";
|
||||||
@@ -49,13 +43,11 @@ function normalizePublicHref(input?: string) {
|
|||||||
---
|
---
|
||||||
|
|
||||||
<DefaultLayout title={pageTitle} description={pageDesc}>
|
<DefaultLayout title={pageTitle} description={pageDesc}>
|
||||||
{/* CONTENT */}
|
|
||||||
<section class="f-section">
|
<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>
|
<div>
|
||||||
<h3 class="f-section-title">{left.tytul ?? "Przeczytaj"}</h3>
|
<h3 class="f-section-title mt-0">{left.tytul ?? "Przeczytaj"}</h3>
|
||||||
|
|
||||||
{!left.pliki?.length ? (
|
{!left.pliki?.length ? (
|
||||||
<p class="opacity-70 mt-4">Brak dokumentów.</p>
|
<p class="opacity-70 mt-4">Brak dokumentów.</p>
|
||||||
@@ -68,9 +60,7 @@ function normalizePublicHref(input?: string) {
|
|||||||
href={`/dokumenty/${p.slug}`}
|
href={`/dokumenty/${p.slug}`}
|
||||||
title={p.nazwa}
|
title={p.nazwa}
|
||||||
>
|
>
|
||||||
{/* <div class="f-document-icon">📖</div> */}
|
|
||||||
<div class="f-document-title">{p.nazwa}</div>
|
<div class="f-document-title">{p.nazwa}</div>
|
||||||
{/* <div class="f-document-meta">Otwórz</div> */}
|
|
||||||
</a>
|
</a>
|
||||||
) : null
|
) : null
|
||||||
))}
|
))}
|
||||||
@@ -79,7 +69,7 @@ function normalizePublicHref(input?: string) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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 ? (
|
{!right.pliki?.length ? (
|
||||||
<p class="opacity-70 mt-4">Brak plików.</p>
|
<p class="opacity-70 mt-4">Brak plików.</p>
|
||||||
@@ -106,4 +96,4 @@ function normalizePublicHref(input?: string) {
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</DefaultLayout>
|
</DefaultLayout>
|
||||||
@@ -10,8 +10,19 @@ import { loadYamlFile } from "../../lib/loadYaml";
|
|||||||
type SeoYaml = any;
|
type SeoYaml = any;
|
||||||
|
|
||||||
type InternetParam = { klucz: string; label: string; value: string | number };
|
type InternetParam = { klucz: string; label: string; value: string | number };
|
||||||
type InternetCena = { budynek: number | string; umowa: number | string; miesiecznie: number; aktywacja?: number };
|
type InternetCena = {
|
||||||
type InternetCard = { nazwa: string; widoczny?: boolean; popularny?: boolean; parametry?: InternetParam[]; ceny?: 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 = {
|
type InternetCardsYaml = {
|
||||||
tytul?: string;
|
tytul?: string;
|
||||||
opis?: string;
|
opis?: string;
|
||||||
@@ -22,18 +33,46 @@ type InternetCardsYaml = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type PhoneParam = { klucz: string; label: string; value: string | number };
|
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 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[] };
|
type AddonsYaml = { cena_opis?: string; dodatki?: Addon[] };
|
||||||
|
|
||||||
const seo = loadYamlFile<SeoYaml>(
|
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>(
|
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>(
|
const phoneData = loadYamlFile<PhoneCardsYaml>(
|
||||||
@@ -41,7 +80,13 @@ const phoneData = loadYamlFile<PhoneCardsYaml>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const addonsData = loadYamlFile<AddonsYaml>(
|
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 ?? "";
|
const tytul = data?.tytul ?? "";
|
||||||
@@ -51,17 +96,21 @@ const uwaga = data?.uwaga ?? "";
|
|||||||
const waluta = data?.waluta ?? "PLN";
|
const waluta = data?.waluta ?? "PLN";
|
||||||
const cenaOpis = data?.cena_opis ?? "zł/mies.";
|
const cenaOpis = data?.cena_opis ?? "zł/mies.";
|
||||||
|
|
||||||
const cards = (Array.isArray(data?.cards)
|
const cards = (
|
||||||
? data.cards.filter((c) => c?.widoczny === true)
|
Array.isArray(data?.cards)
|
||||||
: []) as InternetCard[];
|
? data.cards.filter((c) => c?.widoczny === true)
|
||||||
|
: []
|
||||||
|
) as InternetCard[];
|
||||||
|
|
||||||
const phoneCards = (Array.isArray(phoneData?.cards)
|
const phoneCards = (
|
||||||
? phoneData.cards.filter((c) => c?.widoczny === true)
|
Array.isArray(phoneData?.cards)
|
||||||
: []) as PhoneCard[];
|
? phoneData.cards.filter((c) => c?.widoczny === true)
|
||||||
|
: []
|
||||||
|
) as PhoneCard[];
|
||||||
|
|
||||||
const addons = (Array.isArray(addonsData?.dodatki)
|
const addons = (
|
||||||
? addonsData.dodatki
|
Array.isArray(addonsData?.dodatki) ? addonsData.dodatki : []
|
||||||
: []) as Addon[];
|
) as Addon[];
|
||||||
|
|
||||||
const addonsCenaOpis = addonsData?.cena_opis ?? cenaOpis;
|
const addonsCenaOpis = addonsData?.cena_opis ?? cenaOpis;
|
||||||
|
|
||||||
@@ -79,9 +128,9 @@ const switchesData = loadYamlFile<SwitchesYaml>(
|
|||||||
path.join(process.cwd(), "src", "content", "site", "switches.yaml"),
|
path.join(process.cwd(), "src", "content", "site", "switches.yaml"),
|
||||||
);
|
);
|
||||||
|
|
||||||
const switches = (Array.isArray(switchesData?.switches)
|
const switches = (
|
||||||
? switchesData.switches
|
Array.isArray(switchesData?.switches) ? switchesData.switches : []
|
||||||
: []) as SwitchDef[];
|
) as SwitchDef[];
|
||||||
---
|
---
|
||||||
|
|
||||||
<DefaultLayout seo={seo}>
|
<DefaultLayout seo={seo}>
|
||||||
@@ -100,9 +149,9 @@ const switches = (Array.isArray(switchesData?.switches)
|
|||||||
addonsCenaOpis={addonsCenaOpis}
|
addonsCenaOpis={addonsCenaOpis}
|
||||||
switches={switches}
|
switches={switches}
|
||||||
/>
|
/>
|
||||||
|
<p><span class="f-card-price text-sm">* </span>{uwaga}</p>
|
||||||
</div>
|
</div>
|
||||||
<p><span class="f-card-price text-sm">* </span>{uwaga}</p>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<SectionRenderer src="./src/content/internet-swiatlowodowy/section.yaml" />
|
<SectionRenderer src="./src/content/internet-swiatlowodowy/section.yaml" />
|
||||||
</DefaultLayout>
|
</DefaultLayout>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.f-offers {
|
/* .f-offers {
|
||||||
@apply my-6;
|
@apply my-6;
|
||||||
}
|
} */
|
||||||
|
|
||||||
.f-offers-grid {
|
.f-offers-grid {
|
||||||
@apply flex flex-wrap justify-center gap-8;
|
@apply flex flex-wrap justify-center gap-8;
|
||||||
|
|||||||
@@ -13,6 +13,10 @@
|
|||||||
@apply f-section text-center;
|
@apply f-section text-center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.f-section-grid-top {
|
||||||
|
@apply grid gap-5 max-w-7xl mx-auto mt-8;
|
||||||
|
}
|
||||||
|
|
||||||
.f-section-grid {
|
.f-section-grid {
|
||||||
@apply grid items-center gap-5 max-w-7xl mx-auto mt-8;
|
@apply grid items-center gap-5 max-w-7xl mx-auto mt-8;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user