-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
18 lines (18 loc) · 752 Bytes
/
script.js
File metadata and controls
18 lines (18 loc) · 752 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
document.addEventListener("DOMContentLoaded", function() {
fetch("blog_posts.json")
.then(response => response.json())
.then(data => {
const blogPostsContainer = document.querySelector(".blog-posts");
data.forEach(post => {
const postElement = document.createElement("div");
postElement.classList.add("blog-post");
postElement.innerHTML = `
<h3>${post.title}</h3>
<p>${post.content}</p>
<span>${post.date}</span>
`;
blogPostsContainer.appendChild(postElement);
});
})
.catch(error => console.error("Error fetching blog posts:", error));
});