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.
This commit is contained in:
@@ -455,15 +455,19 @@ body { font-family: var(--sans); background: var(--bg); color: var(--text); heig
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
statFile.textContent = 'Loading...';
|
statFile.textContent = 'Loading...';
|
||||||
fetch('/api/file/' + encodeURIComponent(fileVault) + '?path=' + encodeURIComponent(filePath))
|
fetch('/api/file/' + encodeURIComponent(fileVault) + '/raw?path=' + encodeURIComponent(filePath))
|
||||||
.then(function(r) {
|
.then(function(r) {
|
||||||
if (!r.ok) throw new Error('HTTP ' + r.status);
|
if (!r.ok) throw new Error('HTTP ' + r.status);
|
||||||
return r.json();
|
return r.json();
|
||||||
})
|
})
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
ta.value = data.content || data.raw || '';
|
ta.value = data.raw || '';
|
||||||
originalContent = ta.value;
|
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;
|
statFile.textContent = fileVault + '/' + filePath;
|
||||||
updateStats();
|
updateStats();
|
||||||
schedulePreview();
|
schedulePreview();
|
||||||
|
|||||||
Reference in New Issue
Block a user