Knowledge Base Management System
Welcome to your Knowledge Base
Select an article from the left to read, or create a new one.
Create New Article
No articles found.
'; return; } filteredArticles.forEach(article => { const link = document.createElement('a'); link.href = '#'; link.className = `block p-3 rounded-lg hover:bg-gray-100 ${article.id === currentArticleId ? 'bg-blue-50 font-semibold text-blue-700' : ''}`; link.dataset.id = article.id; link.innerHTML = ` ${article.title} ${article.category} `; link.onclick = (e) => { e.preventDefault(); displayArticle(article.id); }; articleList.appendChild(link); }); } function displayArticle(id) { const article = knowledgeBase.find(a => a.id === id); if (!article) { showWelcomeMessage(); return; } currentArticleId = id; // Simple markdown to HTML conversion let contentHtml = article.content .replace(/^# (.*$)/gim, '$1
') .replace(/^## (.*$)/gim, '$1
') .replace(/\n- (.*$)/gim, '- \n
- $1 \n
- \n
- $2 \n
- /g, '') // Merge consecutive lists
.replace(/<\/ol>\s*
- /g, '');
articleViewContent.innerHTML = `
${article.category}
${article.title}
${contentHtml}
`;
viewActions.classList.remove('hidden');
switchMode('view');
renderArticleList(searchInput.value);
}
function showWelcomeMessage() {
currentArticleId = null;
articleViewContent.innerHTML = `
Welcome to your Knowledge Base
Select an article from the left to read, or create a new one.
