fix: Update findNavigationLink parameter to optional

This commit is contained in:
Gauthier Daniels 2025-04-18 18:41:40 +02:00
parent e33700f13d
commit 668f730692
3 changed files with 3 additions and 5 deletions

View File

@ -133,7 +133,7 @@ export function doesLinkSubitemExist(link: NavigationLink, subitemHref: string):
return link.subitems.some((subitem) => subitem.href === subitemHref);
}
export function findNavigationLink(namespace: string, href: string): NavigationLink | undefined {
export function findNavigationLink(namespace: string, href?: string): NavigationLink | undefined {
const currentUrl = `/${namespace}/${href}`.replace(/\/+/g, "/").replace(/\/$/, "");
const foundLink = navigation

View File

@ -4,7 +4,7 @@ const routeRegex = /^\/docs\/(.*)$/;
export function route(pageContext: PageContext) {
if (pageContext.urlPathname === "/docs") {
return { routeParams: { key: "documentations" } };
return { routeParams: { key: "index" } };
}
const match = pageContext.urlPathname.match(routeRegex);

View File

@ -152,14 +152,12 @@ class DocsService {
};
}
public async getDoc(namespace: "root"): Promise<DocData | undefined>;
public async getDoc(namespace: "docs" | "certifications", key: string): Promise<DocData | undefined>;
public async getDoc(namespace: "root" | "docs" | "certifications", key?: string): Promise<DocData | undefined> {
try {
await this.fetchDocs();
let doc: DocData | undefined;
if (namespace === "root") {
if (namespace === "root" || key === "index") {
doc = this.getFromCache(`/${namespace}`);
} else {
doc = this.getFromCache(`/${namespace}/${key}`);