- Project card expands to show description + status + dates (was only the research stub) - Cards compacted + responsive (actions wrap on narrow) - Sentinel renamed Yerin everywhere (#/yerin, red 'Sage of the Endless Sword' theme + red sidebar dot) - void1 importer now carries research_notes/last_researched_at (was dropped) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
55 lines
2.1 KiB
JavaScript
55 lines
2.1 KiB
JavaScript
// Hash-based router. Routes:
|
|
// #/ home
|
|
// #/space/:id space view
|
|
// #/project/:id project view
|
|
// #/page/:id page view
|
|
// #/ref/:id reference detail
|
|
// #/resource/:id resource detail
|
|
// #/search?q= search results
|
|
// #/inbox pending changes
|
|
// #/sacred-valley dashboard placeholder
|
|
// #/sentinel Yerin security view
|
|
// #/little-blue Little Blue caretaker view
|
|
// Anything unrecognized falls through to the home handler.
|
|
|
|
const ROUTES = [
|
|
{ name: 'space', re: /^\/space\/([^/]+)$/, keys: ['id'] },
|
|
{ name: 'project', re: /^\/project\/([^/]+)$/, keys: ['id'] },
|
|
{ name: 'page', re: /^\/page\/([^/]+)$/, keys: ['id'] },
|
|
{ name: 'ref', re: /^\/ref\/([^/]+)$/, keys: ['id'] },
|
|
{ name: 'resource', re: /^\/resource\/([^/]+)$/, keys: ['id'] },
|
|
{ name: 'search', re: /^\/search$/, keys: [] },
|
|
{ name: 'inbox', re: /^\/inbox$/, keys: [] },
|
|
{ name: 'sacred-valley', re: /^\/sacred-valley$/, keys: [] },
|
|
{ name: 'yerin', re: /^\/(yerin|sentinel)$/, keys: [] },
|
|
{ name: 'little-blue', re: /^\/little-blue$/, keys: [] },
|
|
{ name: 'terminal', re: /^\/terminal$/, keys: [] },
|
|
{ name: 'settings', re: /^\/settings$/, keys: [] },
|
|
{ name: 'jobs', re: /^\/jobs$/, keys: [] },
|
|
{ name: 'home', re: /^\/?$/, keys: [] }
|
|
];
|
|
|
|
export function current() {
|
|
const raw = (location.hash || '#/').slice(1);
|
|
const [path, queryString = ''] = raw.split('?');
|
|
const query = Object.fromEntries(new URLSearchParams(queryString));
|
|
for (const r of ROUTES) {
|
|
const m = path.match(r.re);
|
|
if (m) {
|
|
const params = {};
|
|
r.keys.forEach((k, i) => { params[k] = m[i + 1]; });
|
|
return { name: r.name, params, query, hash: raw };
|
|
}
|
|
}
|
|
return { name: 'home', params: {}, query: {}, hash: raw };
|
|
}
|
|
|
|
export function navigate(hash) {
|
|
location.hash = hash.startsWith('#') ? hash : '#' + hash;
|
|
}
|
|
|
|
export function route(handler) {
|
|
window.addEventListener('hashchange', () => handler(current()));
|
|
handler(current());
|
|
}
|