}
}));
- Alpine.data('notFoundNav', () => ({
- get homeLink() {
- return window.currentLang === 'it' ? '/it/' : '/';
- },
- get articlesLink() {
- return window.currentLang === 'it' ? '/it/articles/' : '/articles/';
- },
- get contactLink() {
- return window.currentLang === 'it' ? '/it/is/here/' : '/is/here/';
- }
- }));
+ Alpine.data('notFoundNav', () => {
+ const isItalian = window.location.pathname.startsWith('/it/');
+ return {
+ get homeLink() {
+ return isItalian ? '/it/' : '/';
+ },
+ get articlesLink() {
+ return isItalian ? '/it/articles/' : '/articles/';
+ },
+ get contactLink() {
+ return isItalian ? '/it/is/here/' : '/is/here/';
+ },
+ goHome() {
+ window.location.href = this.homeLink;
+ },
+ goArticles() {
+ window.location.href = this.articlesLink;
+ },
+ goContact() {
+ window.location.href = this.contactLink;
+ }
+ };
+ });
console.log('notFoundPage Alpine component registered');
});
<!-- Navigation Links -->
<div class="space-y-4 flex flex-col items-center mb-12" x-data="notFoundNav()">
- <a :href="homeLink" class="btn btn-primary">
+ <a :href="homeLink" @click.prevent="goHome()" class="btn btn-primary">
{{ i18n "goHome" }}
</a>
- <a :href="articlesLink" class="btn btn-secondary">
+ <a :href="articlesLink" @click.prevent="goArticles()" class="btn btn-secondary">
{{ i18n "browseArticles" }}
</a>
- <a :href="contactLink" class="btn btn-outline">
+ <a :href="contactLink" @click.prevent="goContact()" class="btn btn-outline">
{{ i18n "contactSupport" }}
</a>
</div>