summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-01-25 10:58:18 +0200
committerPaul Buetow <paul@buetow.org>2026-01-25 10:58:18 +0200
commit96323477c4811b9b310511c881e9856e18cada7e (patch)
treeb971f1692ccbf7d3cff3f13499009198d7ccd61b /js
parentb909ac9f51c65beb75364ed287f08031d3441dde (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.js35
1 files changed, 31 insertions, 4 deletions
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 = `
<h3>Summary</h3>
- <p>${escapeHtml(book.summary)}</p>
- ${book.summarySource ? `<p class="summary-source">Source: ${book.summarySource}</p>` : ''}
+ <p>${escapeHtml(summary)}</p>
`;
} else {
summaryHtml = `