File size: 5,640 Bytes
df9c8a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// 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();
    }
}