Graph calculator improvmentes
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 24s
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 24s
This commit is contained in:
@@ -64,3 +64,35 @@ export function versionHref(identity: string, language?: string): string {
|
||||
export function isReadingSurface(path: string): boolean {
|
||||
return isReaderPath(path) || WIKI_SUB_PATH.test(path) || path === '/new'
|
||||
}
|
||||
|
||||
/* ---------- the wiki's own pages ----------
|
||||
|
||||
The link map and the graphing calculator are pages the shelf holds no
|
||||
copies of — but the book can read them too. Each has one plain address of
|
||||
its own, and useArticleTabs can lay it on the row beside the open articles:
|
||||
the page then draws the live surface instead of an article, for as long as
|
||||
its page stays open. */
|
||||
|
||||
export type ToolPage = 'graph' | 'calculator'
|
||||
|
||||
const TOOL_PAGE_PATHS: Record<ToolPage, string> = {
|
||||
graph: '/graph',
|
||||
calculator: '/calculator',
|
||||
}
|
||||
|
||||
/** The address a tool page lives at. */
|
||||
export function toolHref(page: ToolPage): string {
|
||||
return TOOL_PAGE_PATHS[page]
|
||||
}
|
||||
|
||||
/** Which tool page an address names, if any. */
|
||||
export function toolFromPath(path: string): ToolPage | null {
|
||||
const clean = path.replace(/\/+$/, '')
|
||||
for (const page of Object.keys(TOOL_PAGE_PATHS) as ToolPage[])
|
||||
if (clean === TOOL_PAGE_PATHS[page]) return page
|
||||
return null
|
||||
}
|
||||
|
||||
export function isToolPath(path: string): boolean {
|
||||
return toolFromPath(path) !== null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user