mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-06-22 04:18:50 -07:00
28 lines
724 B
JavaScript
28 lines
724 B
JavaScript
import { createBuildPage } from "./build/index.js";
|
|
import { createExplorePage } from "./explore/index.js";
|
|
import { createHomePage } from "./home/index.js";
|
|
import { createLearnPage } from "./learn/index.js";
|
|
|
|
/** @type {Record<string, () => HTMLElement>} */
|
|
const routes = {
|
|
"/": createHomePage,
|
|
"/explore": createExplorePage,
|
|
"/learn": createLearnPage,
|
|
"/build": createBuildPage,
|
|
};
|
|
|
|
/** @param {string} pathname */
|
|
export function isRoute(pathname) {
|
|
return pathname in routes;
|
|
}
|
|
|
|
/** @param {string} pathname */
|
|
export function normalizePath(pathname) {
|
|
return isRoute(pathname) ? pathname : "/";
|
|
}
|
|
|
|
/** @param {string} pathname */
|
|
export function createRoutePage(pathname) {
|
|
return routes[pathname]();
|
|
}
|