diff options
| author | Paul Buetow <paul@buetow.org> | 2026-01-25 10:58:18 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-01-25 10:58:18 +0200 |
| commit | 96323477c4811b9b310511c881e9856e18cada7e (patch) | |
| tree | b971f1692ccbf7d3cff3f13499009198d7ccd61b /js | |
| parent | b909ac9f51c65beb75364ed287f08031d3441dde (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'js')
| -rw-r--r-- | js/app.js | 35 |
1 files changed, 31 insertions, 4 deletions
@@ -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 = ` <h3>Summary</h3> - <p>${escapeHtml(book.summary)}</p> - ${book.summarySource ? `<p class="summary-source">Source: ${book.summarySource}</p>` : ''} + <p>${escapeHtml(summary)}</p> `; } else { summaryHtml = ` |
