Files
task-inventory/public/lib/api.mjs
mikael-lovqvists-claude-agent 444b51794a Add Gitea markdown rendering and Edit/Preview tabs
- New /api/render-markdown proxy to Gitea (configured via config.yaml)
- lib/config.mjs loads config.yaml with yaml-js
- Edit/Preview tabs on the body field in the task dialog
- Title and body rendered as markdown inline in the task list
- Gitea markup+chroma CSS extracted and vendored to public/gitea-markup.css
- Markdown cached in memory per text string

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-17 18:19:29 +00:00

18 lines
773 B
JavaScript

async function req(method, path, body) {
const opts = { method, headers: {} };
if (body !== undefined) {
opts.headers['Content-Type'] = 'application/json';
opts.body = JSON.stringify(body);
}
const res = await fetch(path, opts);
const data = await res.json();
if (!data.ok) { throw new Error(data.error ?? 'Request failed'); }
return data;
}
export const get_tasks = () => req('GET', '/api/tasks');
export const create_task = (body) => req('POST', '/api/tasks', body);
export const update_task = (id, body) => req('PUT', `/api/tasks/${id}`, body);
export const delete_task = (id) => req('DELETE', `/api/tasks/${id}`);
export const render_markdown = (text) => req('POST', '/api/render-markdown', { text });