Create get-posts.js
Browse files1234567891011121314151617181920212223242526272829303132333435document.addEventListener('DOMContentLoaded', () => { const container = document.getElementById('posts-container');
fetch('sad.json') .then(response => { if (!response.ok) { throw new Error('Failed to load sad.json'); } return response.json(); }) .then(data => { data.posts.forEach(post => { const postElement = document.createElement('div'); postElement.classList.add('post');
const titleElement = document.createElement('h2'); titleElement.textContent = post['post-title'];
const fileElement = document.createElement('a'); fileElement.href = post.file; fileElement.textContent = `${post.file}`;
postElement.appendChild(titleElement); postElement.appendChild(fileElement);
container.appendChild(postElement); }); }) .catch(error => { console.error('Error loading posts:', error); const errorElement = document.createElement('p'); errorElement.textContent = 'Failed to load posts. Check console for details.'; container.appendChild(errorElement); });});get-posts.jsAdded+35