Post Title
+ +
+
+ This is a placeholder paragraph for the blog post content. Replace with real content.
+diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..e171400 Binary files /dev/null and b/backend/requirements.txt differ diff --git a/blog-page.html b/blog-page.html new file mode 100644 index 0000000..f02a8f5 --- /dev/null +++ b/blog-page.html @@ -0,0 +1,87 @@ + + +
+ + +This is a placeholder paragraph for the blog post content. Replace with real content.
+No post selected.
'; + } +} + +document.addEventListener('DOMContentLoaded', ()=>{ + renderPostList(); + + document.getElementById('create-post-btn').addEventListener('click', ()=> openForm('create')); + + document.getElementById('cancel-post-btn').addEventListener('click', (e)=>{ e.preventDefault(); closeForm(); }); + + document.getElementById('posts-list').addEventListener('click', (e)=>{ + const btn = e.target.closest('button[data-action]'); + if (!btn) return; + const id = parseInt(btn.dataset.id,10); + const action = btn.dataset.action; + if (action === 'view') showPost(id); + if (action === 'edit') { + const posts = loadPosts(); + const post = posts.find(p=>p.id===id); + openForm('edit', post); + } + if (action === 'delete') deletePost(id); + }); + + document.getElementById('blog-form').addEventListener('submit', (e)=>{ + e.preventDefault(); + const form = e.target; + const mode = form.dataset.mode || 'create'; + const id = parseInt(form.dataset.id,10) || null; + const title = document.getElementById('post-title-input').value.trim(); + const journeyId = document.getElementById('post-journey-input').value.trim() || null; + const image = document.getElementById('post-image-input').value.trim() || ''; + const content = document.getElementById('post-content-input').value.trim(); + + let posts = loadPosts(); + if (mode === 'create') { + const newPost = { + id: getNextId(posts), + title, + content, + image, + journeyId: journeyId || null, + created_at: new Date().toISOString() + }; + posts.push(newPost); + savePosts(posts); + renderPostList(); + showPost(newPost.id); + } else if (mode === 'edit' && id) { + const idx = posts.findIndex(p=>p.id===id); + if (idx !== -1) { + posts[idx].title = title; + posts[idx].content = content; + posts[idx].image = image; + posts[idx].journeyId = journeyId || null; + savePosts(posts); + renderPostList(); + showPost(id); + } + } + + closeForm(); + }); +}); +
Comments
+ +