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 // src/components/Banner.astro
import "../styles/components/Banner.css" 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 id="banner-container"></div>
<div class="banner-wrapper">
<div class="banner container"> <script>
<p>{banner.text}</p> const API_BASE = 'https://cms.gallus-pub.ch';
</div>
</div> 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>