Create a travel blog with full-width destination photos, travel stories grid, interactive world map showing visited places, travel tips section, gear recommendations, and subscription form.
df9c8a3 verified Download script.js from Daskstyles/wanderlust-chronicles: direct link, hf CLI and curl.
- Browser
- Download file 5.64 kB
-
https://huggingface.co/spaces/Daskstyles/wanderlust-chronicles/resolve/main/script.js
- Command line
-
hf download hf://spaces/Daskstyles/wanderlust-chronicles/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Daskstyles/wanderlust-chronicles/resolve/main/script.js
5.64 kB
| // Main JavaScript for the travel blog | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Initialize map | |
| initMap(); | |
| // Load travel stories | |
| loadStories(); | |
| // Theme toggle functionality | |
| const themeToggle = document.getElementById('theme-toggle'); | |
| if (themeToggle) { | |
| themeToggle.addEventListener('click', toggleTheme); | |
| } | |
| }); | |
| function initMap() { | |
| const map = L.map('map').setView([20, 0], 2); | |
| // Add marker clusters | |
| const markers = L.markerClusterGroup(); | |
| // Sample visited locations | |
| const locations = [ | |
| { lat: 36.2048, lng: 138.2529, title: 'Japan', story: 'Explored ancient temples in Kyoto' }, | |
| { lat: 36.3932, lng: 25.4615, title: 'Santorini', story: 'Sunset views in Oia' }, | |
| { lat: 40.7128, lng: -74.0060, title: 'New York', story: 'Concrete jungle where dreams are made' }, | |
| { lat: -13.1631, lng: -72.5450, title: 'Machu Picchu', story: 'Hiked the Inca Trail to the lost city' }, | |
| { lat: -22.9519, lng: -43.2105, title: 'Rio de Janeiro', story: 'Christ the Redeemer and Copacabana' }, | |
| { lat: 51.5074, lng: -0.1278, title: 'London', story: 'Afternoon tea and Big Ben' }, | |
| { lat: 48.8566, lng: 2.3522, title: 'Paris', story: 'Croissants and the Eiffel Tower' }, | |
| { lat: -33.8688, lng: 151.2093, title: 'Sydney', story: 'Opera House and Bondi Beach' } | |
| ]; | |
| locations.forEach(loc => { | |
| const marker = L.marker([loc.lat, loc.lng]).bindPopup(` | |
| <div class="text-neutral-900"> | |
| <h3 class="font-bold text-lg">${loc.title}</h3> | |
| <p class="text-sm">${loc.story}</p> | |
| <a href="#" class="text-primary-500 text-sm hover:underline">Read story</a> | |
| </div> | |
| `); | |
| markers.addLayer(marker); | |
| }); | |
| map.addLayer(markers); | |
| // Disable default map tiles since we're using a custom background | |
| map.attributionControl.setPrefix(''); | |
| } | |
| function loadStories() { | |
| const storiesContainer = document.getElementById('stories-container'); | |
| if (!storiesContainer) return; | |
| const stories = [ | |
| { | |
| title: "Hiking the Inca Trail", | |
| excerpt: "My 4-day journey to Machu Picchu through ancient paths and stunning scenery.", | |
| location: "Peru", | |
| date: "May 2023", | |
| image: "http://static.photos/travel/640x360/4" | |
| }, | |
| { | |
| title: "Island Hopping in Greece", | |
| excerpt: "Discovering the hidden gems of the Cyclades beyond Santorini and Mykonos.", | |
| location: "Greece", | |
| date: "August 2022", | |
| image: "http://static.photos/travel/640x360/5" | |
| }, | |
| { | |
| title: "Tokyo's Hidden Izakayas", | |
| excerpt: "An insider's guide to the best small bars and local drinking spots in Tokyo.", | |
| location: "Japan", | |
| date: "November 2022", | |
| image: "http://static.photos/travel/640x360/6" | |
| }, | |
| { | |
| title: "Road Tripping Iceland's Ring Road", | |
| excerpt: "8 days of waterfalls, glaciers, and midnight sun around Iceland's Route 1.", | |
| location: "Iceland", | |
| date: "June 2021", | |
| image: "http://static.photos/travel/640x360/7" | |
| }, | |
| { | |
| title: "Safari in the Serengeti", | |
| excerpt: "Witnessing the Great Migration and staying in luxury tented camps.", | |
| location: "Tanzania", | |
| date: "September 2021", | |
| image: "http://static.photos/travel/640x360/8" | |
| }, | |
| { | |
| title: "Culinary Tour of Vietnam", | |
| excerpt: "From pho in Hanoi to banh mi in Saigon - a food lover's paradise.", | |
| location: "Vietnam", | |
| date: "March 2022", | |
| image: "http://static.photos/travel/640x360/9" | |
| } | |
| ]; | |
| let html = ''; | |
| stories.forEach(story => { | |
| html += ` | |
| <div class="bg-neutral-800 rounded-xl overflow-hidden hover:shadow-lg transition-shadow"> | |
| <div class="relative h-48 overflow-hidden"> | |
| <img src="${story.image}" alt="${story.title}" class="w-full h-full object-cover"> | |
| <div class="absolute top-4 right-4 bg-black/70 text-white px-3 py-1 rounded-full text-sm"> | |
| ${story.location} | |
| </div> | |
| </div> | |
| <div class="p-6"> | |
| <div class="flex justify-between items-start mb-2"> | |
| <h3 class="text-xl font-bold">${story.title}</h3> | |
| <span class="text-sm text-neutral-400">${story.date}</span> | |
| </div> | |
| <p class="text-neutral-400 mb-4">${story.excerpt}</p> | |
| <a href="#" class="text-primary-500 hover:text-primary-400 font-medium inline-flex items-center"> | |
| Read More | |
| <i data-feather="arrow-right" class="ml-2 w-4 h-4"></i> | |
| </a> | |
| </div> | |
| </div> | |
| `; | |
| }); | |
| storiesContainer.innerHTML = html; | |
| feather.replace(); | |
| } | |
| function toggleTheme() { | |
| const html = document.documentElement; | |
| html.classList.toggle('dark'); | |
| // Store preference in localStorage | |
| const isDark = html.classList.contains('dark'); | |
| localStorage.setItem('darkMode', isDark); | |
| // Update button icon | |
| const icon = document.getElementById('theme-icon'); | |
| if (icon) { | |
| icon.setAttribute('data-feather', isDark ? 'sun' : 'moon'); | |
| feather.replace(); | |
| } | |
| } |