blob: ec427080fec50981b42a01449ee4192529345118 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
document.addEventListener('alpine:init', () => {
Alpine.data('notFoundPage', () => ({
showEasterEgg: false,
searchQuery: '',
filteredArticles: [],
allArticles: window.articlesData || [],
filterArticles(query) {
this.searchQuery = query.toLowerCase();
if (!this.searchQuery) {
this.filteredArticles = [];
return;
}
this.filteredArticles = this.allArticles.filter(article =>
article.title.toLowerCase().includes(this.searchQuery) ||
article.content.toLowerCase().includes(this.searchQuery)
).slice(0, 5);
},
toggleEasterEgg() {
this.showEasterEgg = !this.showEasterEgg;
},
goToRandomArticle() {
if (this.allArticles.length > 0) {
const randomArticle = this.allArticles[Math.floor(Math.random() * this.allArticles.length)];
window.location.href = randomArticle.url;
}
}
}));
});
|