From 96323477c4811b9b310511c881e9856e18cada7e Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 25 Jan 2026 10:58:18 +0200 Subject: Move summaries to markdown files for easier editing - Extract summaries from books.json to summaries/{id}.md files - Update app.js to fetch summaries dynamically from markdown - Remove summary/summarySource fields from books.json - Update AGENTS.md and CLAUDE.md documentation - Add file:// protocol warning (must use HTTP server) Co-Authored-By: Claude Opus 4.5 --- js/app.js | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'js') diff --git a/js/app.js b/js/app.js index 3e7f1e8..49de49e 100644 --- a/js/app.js +++ b/js/app.js @@ -188,20 +188,47 @@ function setupModal() { }); } +// Fetch summary from markdown file +async function fetchSummary(bookId) { + // Check if running from file:// protocol (fetch won't work) + if (window.location.protocol === 'file:') { + console.warn('Running from file:// - use "python -m http.server 8000" for summaries'); + return null; + } + + try { + const response = await fetch(`summaries/${bookId}.md`); + if (!response.ok) { + console.warn(`Summary not found for book ${bookId}: ${response.status}`); + return null; + } + const text = await response.text(); + // Skip the title line (# Title) and return the rest + const lines = text.trim().split('\n'); + const summaryLines = lines.slice(1).join('\n').trim(); + return summaryLines || null; + } catch (error) { + console.error('Error fetching summary:', error); + return null; + } +} + // Open modal with book details -function openModal(bookId) { +async function openModal(bookId) { const book = state.books.find(b => b.id === bookId); if (!book) return; const coverUrl = getCoverUrl(book); + // Fetch summary from markdown file + const summary = await fetchSummary(bookId); + // Build summary section let summaryHtml; - if (book.summary) { + if (summary) { summaryHtml = `

Summary

-

${escapeHtml(book.summary)}

- ${book.summarySource ? `

Source: ${book.summarySource}

` : ''} +

${escapeHtml(summary)}

`; } else { summaryHtml = ` -- cgit v1.2.3