feat: Add Banner component for fetching and displaying active banners
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

- Implemented `Banner.astro` component to retrieve active banners from the CMS.
- Integrated styling via `Banner.css`.
- Handles errors gracefully during banner fetch.
This commit is contained in:
2025-12-17 20:59:23 +01:00
parent 20feee84a6
commit 2b64a21f16

View File

@ -0,0 +1,26 @@
---
// src/components/Banner.astro
import "../styles/components/Banner.css"
const API_BASE = 'https://cms.gallus-pub.ch';
let banner = null;
try {
const response = await fetch(`${API_BASE}/api/banners/active`);
if (response.ok) {
const data = await response.json();
banner = data.banner;
}
} catch (error) {
console.error('Failed to fetch banner:', error);
}
---
{banner && (
<div class="banner-wrapper">
<div class="banner container">
<p>{banner.text}</p>
</div>
</div>
)}