const posts = [ { title: "Mi primer post post post post", date: new Date("2024-08-24"), content: `¡Hola a todxs! Este es mi primer post en este blog, tenía ilusión de volver a hacer un blog en algún punto de mi vida como antes, así sí, esto es por pura nostalgia. Me costo pensar donde hacer esta bitacora, me quería ir a la segura haciendo un blogspot, pero no me gusta el diseño la verdad, asi que solo fui investigando por aqui y por alla websites que me dejaran crear esto (sin pagar niun peso porque estoy pato) y encontre esta. También tenia la nostalgia brijida y quería que tenga una aesthetic de los 2000s, aquí puedo lograr eso, pero es todo muy manual y debo escribirlo en codigo todo todo todo, es una paja, pero bueno, me gustan los resultados...` }, // Agrega más posts aquí siguiendo la misma estructura ]; const postsPerPage = 3; let currentPage = 1; function displayPosts() { const startIndex = (currentPage - 1) * postsPerPage; const endIndex = startIndex + postsPerPage; const postsToDisplay = posts.slice(startIndex, endIndex); const postsContainer = document.getElementById('posts'); postsContainer.innerHTML = ''; postsToDisplay.forEach(post => { const postDiv = document.createElement('div'); postDiv.className = 'post justificado'; postDiv.innerHTML = `

${post.title}

Publicado el ${post.date.toLocaleDateString()}

${post.content}

`; postsContainer.appendChild(postDiv); }); setupPagination(); } function setupPagination() { const paginationContainer = document.getElementById('pagination'); paginationContainer.innerHTML = ''; const pageCount = Math.ceil(posts.length / postsPerPage); for (let i = 1; i <= pageCount; i++) { const pageLink = document.createElement('span'); pageLink.className = 'page-link'; pageLink.innerText = i; pageLink.onclick = () => { currentPage = i; displayPosts(); }; paginationContainer.appendChild(pageLink); } } displayPosts();