feat(spaces): docs-kind spaces render as pure documentation repos
Adds a `kind` column to spaces ('project' default, 'docs' for Wiki).
Docs spaces skip projects/tasks fetches and render only the page tree.
Sidebar caret for docs spaces expands to top-level pages (#/page/:id).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,39 @@ export async function render(main, ctx) {
|
||||
try { space = await api.get('/api/spaces/' + id); }
|
||||
catch (e) { mount(main, el('h1', { class: 'view-h1' }, 'Space not found'), el('p', { class: 'view-sub muted' }, e.message)); return; }
|
||||
|
||||
const docHead = el('div', { class: 'doc-head' },
|
||||
el('h1', { class: 'view-h1', style: { margin: '0' } }, space.name),
|
||||
exportMenu({
|
||||
filenameBase: 'space-' + (space.slug || space.name),
|
||||
getContent: async () => {
|
||||
const allPages = await api.get(`/api/spaces/${id}/pages`).catch(() => []);
|
||||
const full = await Promise.all(allPages.map(p => api.get('/api/pages/' + p.id).catch(() => null)));
|
||||
const md = full.filter(Boolean).map(p => `# ${p.title}\n\n${p.body_md || ''}`).join('\n\n---\n\n');
|
||||
return { title: space.name, md };
|
||||
}
|
||||
})
|
||||
);
|
||||
const descEl = el('p', { class: 'view-sub' }, space.description || el('span', { class: 'muted' }, 'No description.'));
|
||||
|
||||
if (space.kind === 'docs') {
|
||||
// Docs-mode: pure documentation repo — no projects or tasks
|
||||
const [pages, refs] = await Promise.all([
|
||||
api.get(`/api/spaces/${id}/pages`).catch(() => []),
|
||||
api.get(`/api/refs?space_id=${id}&limit=200`).catch(() => [])
|
||||
]);
|
||||
mount(main,
|
||||
docHead,
|
||||
descEl,
|
||||
el('div', { class: 'card' },
|
||||
el('h3', {}, space.name),
|
||||
(pages.length + refs.length) > 0
|
||||
? el('div', {}, renderPageTree(pages, refs))
|
||||
: el('p', { class: 'muted' }, 'Nothing here yet.'))
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Project-mode: full workspace with projects, tasks, and pages
|
||||
let projects = [];
|
||||
const [tasks, pages, refs] = await Promise.all([
|
||||
api.get(`/api/spaces/${id}/tasks?status=todo`).catch(() => []),
|
||||
|
||||
Reference in New Issue
Block a user