fix: load file content from /raw endpoint instead of /view
CI / lint (push) Successful in 14s
CI / security (push) Successful in 9s
CI / test (push) Successful in 26s
CI / build (push) Successful in 2s

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.
This commit is contained in:
2026-06-05 22:30:29 -04:00
parent 6eff157686
commit dcf82e7603
+7 -3
View File
@@ -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();