From dcf82e76036b5c8cae95ab4dc06fc06d696cfc9c Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Fri, 5 Jun 2026 22:30:29 -0400 Subject: [PATCH] fix: load file content from /raw endpoint instead of /view GET /api/file/{vault}?path=... returns html/title but not raw content. Switched to GET /api/file/{vault}/raw?path=... which returns {raw:...}. Title now extracted from first # heading in the content. --- frontend/editor-poc.html | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/editor-poc.html b/frontend/editor-poc.html index 62ad454..33d18e3 100644 --- a/frontend/editor-poc.html +++ b/frontend/editor-poc.html @@ -455,15 +455,19 @@ body { font-family: var(--sans); background: var(--bg); color: var(--text); heig return; } statFile.textContent = 'Loading...'; - fetch('/api/file/' + encodeURIComponent(fileVault) + '?path=' + encodeURIComponent(filePath)) + fetch('/api/file/' + encodeURIComponent(fileVault) + '/raw?path=' + encodeURIComponent(filePath)) .then(function(r) { if (!r.ok) throw new Error('HTTP ' + r.status); return r.json(); }) .then(function(data) { - ta.value = data.content || data.raw || ''; + ta.value = data.raw || ''; originalContent = ta.value; - document.getElementById('poc-title').value = data.title || filePath.split('/').pop().replace(/\.md$/, ''); + // Extract title from first # heading or filename + var title = filePath.split('/').pop().replace(/\.md$/, ''); + var m = ta.value.match(/^#\s+(.+)/m); + if (m) title = m[1]; + document.getElementById('poc-title').value = title; statFile.textContent = fileVault + '/' + filePath; updateStats(); schedulePreview();