fix: Update findNavigationLink parameter to optional
This commit is contained in:
parent
e33700f13d
commit
668f730692
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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}`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user