File size: 7,861 Bytes
0a96199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Blog with Static Dataset</title>
    <style>
        body {
            font-family: 'Inter', sans-serif;
            background: linear-gradient(180deg, #0b1020, #0b1022 30%, #0b1124);
            color: #e2e8f0;
            margin: 0;
            padding: 20px;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
        }
        
        .blog-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
            gap: 2rem;
            margin-top: 2rem;
        }
        
        .blog-card {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 16px;
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.1);
            transition: transform 0.3s ease;
        }
        
        .blog-card:hover {
            transform: translateY(-8px);
        }
        
        .blog-card-image {
            width: 100%;
            height: 200px;
            background-size: cover;
            background-position: center;
        }
        
        .blog-card-content {
            padding: 1.5rem;
        }
        
        .blog-card-title {
            font-size: 1.25rem;
            font-weight: 600;
            margin-bottom: 0.5rem;
        }
        
        .blog-card-date {
            color: #94a3b8;
            font-size: 0.875rem;
            margin-bottom: 1rem;
        }
        
        .blog-card-link {
            color: #8b5cf6;
            text-decoration: none;
            font-weight: 600;
            font-size: 0.875rem;
            text-transform: uppercase;
        }
        
        .search-bar {
            background: rgba(255, 255, 255, 0.1);
            border: 1px solid rgba(255, 255, 255, 0.2);
            border-radius: 25px;
            padding: 0.75rem 1.5rem;
            color: #e2e8f0;
            width: 100%;
            max-width: 400px;
            margin: 2rem auto;
            display: block;
        }
        
        .search-bar::placeholder {
            color: #94a3b8;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>Blog with Dataset Integration</h1>
        
        <input type="text" class="search-bar" placeholder="Search articles..." id="searchInput">
        
        <div class="blog-grid" id="blogGrid">
            <!-- Articles will be loaded here -->
        </div>
    </div>

    <script>
        // Static dataset - you can replace this with your own data
        const newsDataset = [
            {
                title: "The Future of Artificial Intelligence in 2024",
                description: "Exploring the latest developments in AI technology and their impact on various industries.",
                date: "2024-01-15",
                source: "Tech News",
                category: "Technology",
                image: "https://images.unsplash.com/photo-1485827404703-89b55fcc595e?w=500"
            },
            {
                title: "Sustainable Business Practices That Drive Growth",
                description: "How companies are implementing eco-friendly strategies while maintaining profitability.",
                date: "2024-01-14",
                source: "Business Weekly",
                category: "Business",
                image: "https://images.unsplash.com/photo-1554224155-6726b3ff858f?w=500"
            },
            {
                title: "Mental Health Awareness in the Digital Age",
                description: "Understanding the impact of social media and technology on mental well-being.",
                date: "2024-01-13",
                source: "Health Journal",
                category: "Health",
                image: "https://images.unsplash.com/photo-1573496359142-b8d87734a5a2?w=500"
            },
            {
                title: "Climate Change Solutions: What Works",
                description: "Evidence-based approaches to addressing climate change at individual and corporate levels.",
                date: "2024-01-12",
                source: "Environmental Times",
                category: "Environment",
                image: "https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=500"
            },
            {
                title: "The Rise of Remote Work Culture",
                description: "How remote work is reshaping company culture and employee expectations.",
                date: "2024-01-11",
                source: "Workplace Insights",
                category: "Work",
                image: "https://images.unsplash.com/photo-1522202176988-66273c2fd55f?w=500"
            },
            {
                title: "Digital Privacy in the Age of Big Data",
                description: "Protecting personal information in an increasingly connected world.",
                date: "2024-01-10",
                source: "Privacy Today",
                category: "Technology",
                image: "https://images.unsplash.com/photo-1544716278-ca5e3f4abd8c?w=500"
            }
        ];

        // Function to create article cards
        function createArticleCard(article) {
            return `
                <article class="blog-card">
                    <div class="blog-card-image" style="background-image: url('${article.image}');"></div>
                    <div class="blog-card-content">
                        <h3 class="blog-card-title">${article.title}</h3>
                        <p class="blog-card-date">${article.date}${article.source}${article.category}</p>
                        <p style="color: #94a3b8; font-size: 0.875rem; margin-bottom: 1rem;">${article.description}</p>
                        <a href="#" class="blog-card-link">READ MORE</a>
                    </div>
                </article>
            `;
        }

        // Function to display articles
        function displayArticles(articles) {
            const blogGrid = document.getElementById('blogGrid');
            blogGrid.innerHTML = articles.map(createArticleCard).join('');
        }

        // Function to filter articles
        function filterArticles(searchTerm) {
            const filtered = newsDataset.filter(article => 
                article.title.toLowerCase().includes(searchTerm.toLowerCase()) ||
                article.description.toLowerCase().includes(searchTerm.toLowerCase()) ||
                article.category.toLowerCase().includes(searchTerm.toLowerCase()) ||
                article.source.toLowerCase().includes(searchTerm.toLowerCase())
            );
            displayArticles(filtered);
        }

        // Initialize the page
        document.addEventListener('DOMContentLoaded', function() {
            // Display all articles initially
            displayArticles(newsDataset);
            
            // Add search functionality
            const searchInput = document.getElementById('searchInput');
            searchInput.addEventListener('input', function(e) {
                filterArticles(e.target.value);
            });
        });

        // Example: Add new article to dataset
        function addNewArticle(article) {
            newsDataset.push(article);
            displayArticles(newsDataset);
        }

        // Example: Get articles by category
        function getArticlesByCategory(category) {
            return newsDataset.filter(article => article.category === category);
        }

        // Example: Get latest articles
        function getLatestArticles(count = 3) {
            return newsDataset
                .sort((a, b) => new Date(b.date) - new Date(a.date))
                .slice(0, count);
        }
    </script>
</body>
</html>