返回 CodeWhale
docs-navigation.ts
根目录 / web / lib / docs-navigation.ts
1 import { docTopicHref, type DocTopic } from "./docs-map";
2
3 /** Return whether a first-party docs topic owns the current website route. */
4 export function docsTopicIsCurrent(topic: DocTopic, locale: string, pathname: string): boolean {
5 if (!topic.hasPage) return false;
6
7 const normalized = pathname.split(/[?#]/)[0].replace(/\/+$/, "");
8 return normalized === docTopicHref(topic, locale);
9 }
10
10 lines TYPESCRIPT