mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-24 17:38:09 -07:00
website: redesign part 8
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { createBuildPage } from "./build/index.js";
|
||||
import { createExplorePage } from "./explore/index.js";
|
||||
import { createHomePage } from "./home/index.js";
|
||||
import { createLearnPage } from "./learn/index.js";
|
||||
|
||||
const pages = [
|
||||
{ pathname: "/", createPage: createHomePage },
|
||||
{ pathname: "/explore", label: "Explore", createPage: createExplorePage },
|
||||
{ pathname: "/learn", label: "Learn", createPage: createLearnPage },
|
||||
{ pathname: "/build", label: "Build", createPage: createBuildPage },
|
||||
];
|
||||
|
||||
/** @type {Record<string, () => HTMLElement>} */
|
||||
const routes = Object.fromEntries(
|
||||
pages.map(({ pathname, createPage }) => [pathname, createPage]),
|
||||
);
|
||||
|
||||
export const primaryRoutes = pages.flatMap(({ pathname, label }) =>
|
||||
label ? [{ pathname, label }] : [],
|
||||
);
|
||||
|
||||
/** @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]();
|
||||
}
|
||||
Reference in New Issue
Block a user