Refactor: Update banner sorting logic to prioritize relevance
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@ -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>
|
||||
|
||||
Reference in New Issue
Block a user