Refactor: Update banner sorting logic to prioritize relevance
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2025-12-18 13:24:22 +01:00
parent a7d53ffe21
commit 4f12ebaa9a

View File

@ -1,26 +1,36 @@
---
// 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>
)}
<div id="banner-container"></div>
<script>
const API_BASE = 'https://cms.gallus-pub.ch';
async function loadBanner() {
try {
const response = await fetch(`${API_BASE}/api/banners/active`);
if (response.ok) {
const data = await response.json();
if (data.banner) {
const container = document.getElementById('banner-container');
if (container) {
container.innerHTML = `
<div class="banner-wrapper">
<div class="banner container">
<p>${data.banner.text}</p>
</div>
</div>
`;
}
}
}
} catch (error) {
console.error('Failed to fetch banner:', error);
}
}
// Load banner when page loads
loadBanner();
</script>