Section, dodanie sekcji z rozdzieleniem na standardowa i tą pod iframe

This commit is contained in:
dm
2025-11-21 07:17:05 +01:00
parent dafe9deaa6
commit f42a242d9c
17 changed files with 290 additions and 6 deletions

View File

@@ -0,0 +1,36 @@
---
import Markdown from "../../islands/Markdown.jsx";
const { section, index } = Astro.props;
const hasImage = !!section.image;
const reverse = index % 2 === 1;
---
<section class="fuz-section">
<div class={`fuz-section-grid ${hasImage ? "md:grid-cols-2" : "md:grid-cols-1"}`}>
{hasImage && (
<img
src={section.image}
alt={section.title}
class={`fuz-section-image ${reverse ? "md:order-1" : "md:order-2"}
${section.dimmed ? "fuz-image-dimmed" : ""}`}
/>
)}
<div class={`fuz-section-text ${hasImage ? (reverse ? "md:order-2" : "md:order-1") : ""}`}>
<h2 class="fuz-section-title text-center">{section.title}</h2>
<Markdown text={section.content} />
{section.button && (
<div class="mt-8 flex justify-center">
<a href={section.button.url} class="btn btn-outline">
{section.button.text}
</a>
</div>
)}
</div>
</div>
</section>

View File

@@ -0,0 +1,20 @@
---
import IframeChannelSwitcher from "../../islands/ChannelSwitcher.jsx";
const { section } = Astro.props;
---
<section class="fuz-section bg-transparent">
<div class="max-w-7xl mx-auto text-center">
{section.title && (
<h2 class="fuz-section-title">{section.title}</h2>
)}
{section.content && (
<div class="fuz-markdown mb-10" set:html={section.html} />
)}
<IframeChannelSwitcher client:load sets={section.iframe_sets} />
</div>
</section>

View File

@@ -0,0 +1,29 @@
---
import yaml from "js-yaml";
import fs from "fs";
import { marked } from "marked";
import SectionDefault from "./SectionDefault.astro";
import SectionIframeChannels from "./SectionIframeChannels.astro";
const { src } = Astro.props;
// Load YAML
const data = yaml.load(fs.readFileSync(src, "utf8")) ?? { sections: [] };
// Markdown → HTML
const sections = (data.sections as any[]).map((s: any) => ({
...s,
html: marked(s.content || "")
}));
---
{sections.map((section: any, index: number) => {
const type = section.type || "default";
if (type === "iframe-channels") {
return <SectionIframeChannels section={section} index={index} />;
}
return <SectionDefault section={section} index={index} />;
})}