Kolejne poprawki
This commit is contained in:
67
src/components/sections/SectionJamboxMozliwosci.astro
Normal file
67
src/components/sections/SectionJamboxMozliwosci.astro
Normal file
@@ -0,0 +1,67 @@
|
||||
---
|
||||
import Markdown from "../../islands/Markdown.jsx";
|
||||
|
||||
// Pobranie XML Jambox
|
||||
const url = "https://www.jambox.pl/xml/mozliwosci.xml";
|
||||
const xmlText: string = await fetch(url).then(r => r.text());
|
||||
|
||||
// Parser wszystkich <node>
|
||||
function parseNodes(xml: string) {
|
||||
return [...xml.matchAll(/<node>([\s\S]*?)<\/node>/g)].map((match) => {
|
||||
const block = match[1];
|
||||
|
||||
const get = (tag: string) => {
|
||||
const m = block.match(new RegExp(`<${tag}>([\\s\\S]*?)<\\/${tag}>`));
|
||||
return m ? m[1].trim() : "";
|
||||
};
|
||||
|
||||
return {
|
||||
title: get("title"),
|
||||
teaser: get("teaser"),
|
||||
description: get("description"),
|
||||
icon: get("icon"),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const nodes = parseNodes(xmlText);
|
||||
---
|
||||
|
||||
<section class="f-section">
|
||||
<h2 class="f-section-title mb-10">Dodatkowe możliwości telewizji JAMBOX</h2>
|
||||
|
||||
{nodes.map((item, i) => {
|
||||
const reverse = i % 2 === 1;
|
||||
|
||||
return (
|
||||
<div class={`f-section-item py-14`}>
|
||||
<div class={`f-section-grid md:grid-cols-2`}>
|
||||
|
||||
<!-- OBRAZ -->
|
||||
<div class={`${reverse ? "md:order-2" : "md:order-1"}`}>
|
||||
<img
|
||||
src={item.icon}
|
||||
alt={item.title}
|
||||
loading="lazy"
|
||||
class="f-section-image rounded-xl shadow-lg"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- TEKST -->
|
||||
<div class={`f-section-grid ${reverse ? "md:order-1" : "md:order-2"}`}>
|
||||
<h3 class="f-section-title text-2xl mb-4">{item.title}</h3>
|
||||
|
||||
{item.teaser && (
|
||||
<p class="text-lg font-medium opacity-80 mb-4">
|
||||
{item.teaser}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<Markdown text={item.description} />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</section>
|
||||
Reference in New Issue
Block a user