File size: 1,987 Bytes
d543796
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Load content from JSON and update meta tags
document.addEventListener('DOMContentLoaded', function() {
    fetch('content.json')
        .then(response => response.json())
        .then(data => {
            if (window.location.pathname.includes('article')) {
                // Get article slug from URL
                const slug = window.location.pathname.split('/').pop().replace('.html', '');
                const article = data.articles.find(a => a.slug === slug);
                
                if (article) {
                    // Update meta tags for article page
                    document.title = `${article.title} | Moodscape`;
                    document.querySelector('meta[name="description"]').content = article.description;
                    document.querySelector('meta[property="og:title"]').content = `${article.title} | Moodscape`;
                    document.querySelector('meta[property="og:description"]').content = article.description;
                    document.querySelector('meta[property="og:image"]').content = article.image;
                    document.querySelector('meta[property="og:url"]').content = window.location.href;
                }
            } else {
                // Update meta tags for homepage
                document.title = "Moodscape | Discover Your Next Vibe";
                document.querySelector('meta[name="description"]').content = "Explore articles and content that resonate with the stories you love.";
                document.querySelector('meta[property="og:title"]').content = "Moodscape | Discover Your Next Vibe";
                document.querySelector('meta[property="og:description"]').content = "Explore articles and content that resonate with the stories you love.";
                document.querySelector('meta[property="og:url"]').content = window.location.href;
            }
        })
        .catch(error => console.error('Error loading content:', error));
});