UNPKG

alinea

Version:
45 lines (43 loc) 1.21 kB
import "../chunks/chunk-NZLE2WMY.js"; // src/dashboard/DashboardNav.ts var navMatchers = { matchEntry: "/entry/*", matchEntryId: "/:action/:workspace/:root?/:id?", matchWorkspace: "/:action/:workspace", matchRoot: "/:action/:workspace/:root" }; function dashboardNav(defaults) { function loc(location) { const workspace = location?.workspace ?? defaults.workspace; const root2 = location?.root ?? defaults.root; const locale = "locale" in location ? location.locale : defaults.locale; const id = location.id ?? ("id" in location ? location.id : defaults.id); const rootLocation = locale ? `${root2}:${locale}` : root2; if (!id && !root2) return `/${workspace}`; if (!id) return `/${workspace}/${rootLocation}`; return `/${workspace}/${rootLocation}/${id}`; } function root({ id, ...location }) { return entry(location); } function entry(location) { return `/entry${loc(location)}`; } function create(location) { return `${entry(location)}?new`; } function draft(location) { return `/draft${loc(location)}`; } return { root, entry, draft, create, ...navMatchers }; } export { dashboardNav, navMatchers };