-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathposts-loader.js
More file actions
36 lines (32 loc) · 1.02 KB
/
posts-loader.js
File metadata and controls
36 lines (32 loc) · 1.02 KB
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
// Load posts from separate HTML files
async function loadPosts() {
const postsContainer = document.querySelector('.news-posts');
// List of post files to load
const postFiles = [
'posts/work.html',
'posts/publications.html',
'posts/grants.html'
];
try {
// Load all post files
for (const file of postFiles) {
const response = await fetch(file);
if (response.ok) {
const html = await response.text();
postsContainer.innerHTML += html;
} else {
console.error(`Failed to load ${file}`);
}
}
// After loading all posts, ensure filter functionality works
console.log('All posts loaded successfully');
} catch (error) {
console.error('Error loading posts:', error);
}
}
// Load posts when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', loadPosts);
} else {
loadPosts();
}