Empowering Educational Communities
Discover insights, stories, and resources for families, educators, and institutions working together to create brighter futures.
` : '';
return `
${categoryInfo.emoji} ${categoryInfo.name}
${modernBadge}
${post.title}
${post.content.substring(0, 150)}...
${quoteHtml}
👤
${post.author}
📅
${new Date(post.date).toLocaleDateString()}
`;
}
// Minimal Template Style
if (post.isMinimalTemplate) {
return `
${categoryInfo.emoji} ${categoryInfo.name}
${minimalBadge}
${post.title}
${post.content.substring(0, 120)}...
${post.author}
${new Date(post.date).toLocaleDateString()}
`;
}
// Creative Template Style
if (post.isCreativeTemplate) {
return `
${categoryInfo.emoji} ${categoryInfo.name}
${creativeBadge}
${post.emoji}
${post.title}
${post.content.substring(0, 130)}...
👤
${post.author}
📅
${new Date(post.date).toLocaleDateString()}
`;
}
// MwareD Template Style
if (post.isMwaredTemplate) {
const statsHtml = post.stats && post.stats.length > 0 ?
`
${post.stats.map(stat => `
`).join('')}
` : '';
return `
${categoryInfo.emoji} ${categoryInfo.name}
${mwaredBadge}
${getTemplateIcon(post.templateStyle)}
${post.title}
${post.content.substring(0, 150)}...
${statsHtml}
👤
${post.author}
📅
${new Date(post.date).toLocaleDateString()}
`;
}
// Regular Template Style
return `
${categoryInfo.emoji} ${categoryInfo.name}
${canvaBadge}
${post.title}
${post.isCanvaDesign ? 'Interactive Canva design content - click to view full design' : post.content.substring(0, 150) + '...'}
👤
${post.author}
📅
${new Date(post.date).toLocaleDateString()}
`;
}).join('');
}
// Get template icon based on style
function getTemplateIcon(style) {
const icons = {
community: '🏘️',
tech: '💻',
education: '🎓',
success: '🏆'
};
return icons[style] || '🌟';
}
// Open post in modal
function openPost(postId) {
const post = blogPosts.find(p => p.id === postId);
if (!post) return;
const categoryInfo = getCategoryInfo(post.category);
const canvaBadge = post.isCanvaDesign ? '
Canva Design' : '';
const modal = document.createElement('div');
modal.className = 'fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50';
modal.innerHTML = `
${categoryInfo.emoji} ${categoryInfo.name}
${canvaBadge}
${post.title}
👤
${post.author}
📅
${new Date(post.date).toLocaleDateString()}
${post.isCanvaDesign ?
`
Canva Design Content:
${post.content}
` :
`
${post.content}
`
}
`;
document.body.appendChild(modal);
}
// Edit post
function editPost(postId) {
const post = blogPosts.find(p => p.id === postId);
if (!post) return;
document.getElementById('postTitle').value = post.title;
document.getElementById('postContent').value = post.content;
document.getElementById('postAuthor').value = post.author;
document.getElementById('postCategory').value = post.category;
showAddPostForm();
// Change the publish button to update
const publishBtn = document.querySelector('#addPostForm button[onclick="addPost()"]');
publishBtn.textContent = 'Update Post';
publishBtn.setAttribute('onclick', `updatePost(${postId})`);
}
// Update post
function updatePost(postId) {
const title = document.getElementById('postTitle').value.trim();
const content = document.getElementById('postContent').value.trim();
const author = document.getElementById('postAuthor').value.trim();
const category = document.getElementById('postCategory').value;
if (!title || !content || !author) {
alert('Please fill in all fields');
return;
}
const postIndex = blogPosts.findIndex(p => p.id === postId);
if (postIndex !== -1) {
blogPosts[postIndex] = {
...blogPosts[postIndex],
title,
content,
author,
category
};
}
hideAddPostForm();
renderPosts();
showNotification('Post updated successfully!', 'success');
// Reset button
const publishBtn = document.querySelector('#addPostForm button[onclick^="updatePost"]');
publishBtn.textContent = 'Publish Post';
publishBtn.setAttribute('onclick', 'addPost()');
}
// Delete post
function deletePost(postId) {
if (confirm('Are you sure you want to delete this post?')) {
blogPosts = blogPosts.filter(p => p.id !== postId);
renderPosts();
showNotification('Post deleted successfully!', 'success');
}
}
// Load more posts
function loadMorePosts() {
currentPage++;
renderPosts();
}
// Manage categories
function manageCategories() {
alert('Category management feature - you can add custom categories, modify existing ones, and organize your content structure here.');
}
// Show notification
function showNotification(message, type = 'info') {
const notification = document.createElement('div');
notification.className = `fixed top-4 right-4 px-6 py-3 rounded-lg text-white z-50 ${
type === 'success' ? 'bg-green-500' :
type === 'error' ? 'bg-red-500' : 'bg-blue-500'
}`;
notification.textContent = message;
document.body.appendChild(notification);
setTimeout(() => {
notification.remove();
}, 3000);
}
// Initialize blog on page load
document.addEventListener('DOMContentLoaded', initializeBlog);