feat/seo #10
@ -133,7 +133,7 @@ export function doesLinkSubitemExist(link: NavigationLink, subitemHref: string):
|
|||||||
return link.subitems.some((subitem) => subitem.href === subitemHref);
|
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 currentUrl = `/${namespace}/${href}`.replace(/\/+/g, "/").replace(/\/$/, "");
|
||||||
|
|
||||||
const foundLink = navigation
|
const foundLink = navigation
|
||||||
|
|||||||
@ -4,7 +4,7 @@ const routeRegex = /^\/docs\/(.*)$/;
|
|||||||
|
|
||||||
export function route(pageContext: PageContext) {
|
export function route(pageContext: PageContext) {
|
||||||
if (pageContext.urlPathname === "/docs") {
|
if (pageContext.urlPathname === "/docs") {
|
||||||
return { routeParams: { key: "documentations" } };
|
return { routeParams: { key: "index" } };
|
||||||
}
|
}
|
||||||
|
|
||||||
const match = pageContext.urlPathname.match(routeRegex);
|
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> {
|
public async getDoc(namespace: "root" | "docs" | "certifications", key?: string): Promise<DocData | undefined> {
|
||||||
try {
|
try {
|
||||||
await this.fetchDocs();
|
await this.fetchDocs();
|
||||||
let doc: DocData | undefined;
|
let doc: DocData | undefined;
|
||||||
|
|
||||||
if (namespace === "root") {
|
if (namespace === "root" || key === "index") {
|
||||||
doc = this.getFromCache(`/${namespace}`);
|
doc = this.getFromCache(`/${namespace}`);
|
||||||
} else {
|
} else {
|
||||||
doc = this.getFromCache(`/${namespace}/${key}`);
|
doc = this.getFromCache(`/${namespace}/${key}`);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user