feat: move relevant card to the top

This commit is contained in:
Hazel 2025-04-14 17:35:11 +02:00
parent 2b80c90a19
commit 69b3efd78f

View File

@ -21,11 +21,9 @@
</nav> </nav>
<section class="section"> <section class="section">
<div class="container"> <div class="container">
<div class="column is-half is-offset-one-quarter"> <div class="column is-half is-offset-one-quarter">{overview_cards}</div>
{overview_cards} </div>
</div>
</div>
</section> </section>
<!-- Footer --> <!-- Footer -->
@ -35,4 +33,23 @@
</div> </div>
</footer> </footer>
</body> </body>
<script>
document.addEventListener("DOMContentLoaded", function () {
const userLang = "ku" || navigator.language || navigator.userLanguage;
// Normalize and check if the language is not English or German
if (!["en", "de", "de-DE"].includes(userLang)) {
// Try to find a matching card by language attribute
const cardToMove =
document.querySelector(`.card[lang^="${userLang.replace("_", "-").toLowerCase()}"]`) ||
document.querySelector(`.card[lang^="${userLang.split("-")[0]}"]`);
if (cardToMove) {
const container = cardToMove.parentNode;
container.insertBefore(cardToMove, container.firstChild);
}
}
});
</script>
</html> </html>