Rezygnacja z bazy, przeniesienie danych do plików yamla

This commit is contained in:
dm
2025-12-15 06:30:39 +01:00
parent 00d6a57d74
commit 0b6bbbdce7
55 changed files with 3558 additions and 1545 deletions

View File

@@ -1,21 +1,56 @@
---
import path from "node:path";
import DefaultLayout from "../../layouts/DefaultLayout.astro";
import SectionRenderer from "../../components/sections/SectionRenderer.astro";
import OffersPhoneCards from "../../islands/phone/OffersPhoneCards.jsx";
import yaml from "js-yaml";
import fs from "fs";
import { loadYamlFile } from "../../lib/loadYaml";
const seo = yaml.load(
fs.readFileSync("./src/content/telefon/seo.yaml", "utf8"),
type SeoYaml = any;
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 PhoneCardsYaml = {
tytul?: string;
opis?: string;
cards?: PhoneCard[];
};
const seo = loadYamlFile<SeoYaml>(
path.join(process.cwd(), "src", "content", "telefon", "seo.yaml"),
);
const phoneCards = loadYamlFile<PhoneCardsYaml>(
path.join(process.cwd(), "src", "content", "telefon", "cards.yaml"),
);
const tytul = phoneCards?.tytul ?? "";
const opis = phoneCards?.opis ?? "";
const cards: PhoneCard[] = Array.isArray(phoneCards?.cards)
? phoneCards.cards.filter((c) => c?.widoczny === true)
: [];
---
<DefaultLayout seo={seo}>
<section class="f-section">
<div class="f-section-grid-single md:grid-cols-1">
<h1 class="f-section-title">Usługa telefonu</h1>
<OffersPhoneCards client:load />
<OffersPhoneCards client:load title={tytul} description={opis} cards={cards} />
</div>
</section>