68 lines
3.4 KiB
JavaScript
68 lines
3.4 KiB
JavaScript
// Add smooth scrolling to anchor links
|
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
|
anchor.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
|
|
document.querySelector(this.getAttribute('href')).scrollIntoView({
|
|
behavior: 'smooth'
|
|
});
|
|
});
|
|
});
|
|
|
|
// Recommendation Widget
|
|
const recommendations = {
|
|
book: [
|
|
{ title: "The Secret History", author: "Donna Tartt", description: "A dark, academic thriller perfect for a gloomy day." },
|
|
{ title: "Circe", author: "Madeline Miller", description: "A captivating story of Greek mythology and self-discovery." },
|
|
{ title: "Pride and Prejudice", author: "Jane Austen", description: "A timeless romance to warm your heart." },
|
|
],
|
|
movie: [
|
|
{ title: "When Harry Met Sally", director: "Rob Reiner", description: "The quintessential autumn rom-com with beautiful New York scenery." },
|
|
{ title: "Dead Poets Society", director: "Peter Weir", description: "An inspiring story about a passionate teacher at a New England boarding school." },
|
|
{ title: "Knives Out", director: "Rian Johnson", description: "A fun and modern whodunnit with a cozy sweater aesthetic." },
|
|
],
|
|
music: [
|
|
{ title: "folklore", artist: "Taylor Swift", description: "An album with a dreamy, cottagecore vibe." },
|
|
{ title: "Harvest Moon", artist: "Neil Young", description: "A classic album for a crisp autumn evening." },
|
|
{ title: "Bon Iver", artist: "Bon Iver", description: "Ethereal and folksy tunes for introspection." },
|
|
],
|
|
drink: [
|
|
{ title: "Spiced Pumpkin Latte", description: "A classic autumn drink to make you feel warm and cozy." },
|
|
{ title: "Hot Apple Cider", description: "A simple and comforting drink for a chilly day." },
|
|
{ title: "Chai Tea", description: "A fragrant and spicy tea that is perfect for a relaxing afternoon." },
|
|
],
|
|
food: [
|
|
{ title: "Butternut Squash Soup", description: "A creamy and hearty soup that is the essence of autumn." },
|
|
{ title: "Apple Crumble", description: "A warm and delicious dessert that is easy to make." },
|
|
{ title: "Grilled Cheese and Tomato Soup", description: "The ultimate comfort food combination." },
|
|
]
|
|
};
|
|
|
|
const recommendationWidget = document.getElementById('recommendation-widget');
|
|
const recommendationDisplay = document.getElementById('recommendation-display');
|
|
|
|
if (recommendationWidget && recommendationDisplay) {
|
|
recommendationWidget.addEventListener('click', function(e) {
|
|
if (e.target.tagName === 'BUTTON') {
|
|
const category = e.target.dataset.category;
|
|
const items = recommendations[category];
|
|
if (items) {
|
|
const randomIndex = Math.floor(Math.random() * items.length);
|
|
const item = items[randomIndex];
|
|
let html = `<h5>${item.title}</h5>`;
|
|
if (item.author) {
|
|
html += `<p class="mb-1"><em>by ${item.author}</em></p>`;
|
|
}
|
|
if (item.director) {
|
|
html += `<p class="mb-1"><em>dir. by ${item.director}</em></p>`;
|
|
}
|
|
if (item.artist) {
|
|
html += `<p class="mb-1"><em>by ${item.artist}</em></p>`;
|
|
}
|
|
html += `<p class="mb-0">${item.description}</p>`;
|
|
recommendationDisplay.innerHTML = html;
|
|
}
|
|
}
|
|
});
|
|
}
|