Add in the loop test for navigable pages, plus test workflow
This commit is contained in:
@@ -116,11 +116,11 @@ export const siteLayout: navLink[] = [
|
||||
]
|
||||
},
|
||||
// {
|
||||
// title: "Trips",
|
||||
// navText: "Trips",
|
||||
// path: "trips",
|
||||
// children: [
|
||||
// {title: "2025-08 | Alaska ", path: "2025-08-alaska"},
|
||||
// {title: "2024-10 | Norway ", path: "2024-10-norway"}
|
||||
// {navText: "2025-08 | Alaska ", path: "2025-08-alaska"},
|
||||
// {navText: "2024-10 | Norway ", path: "2024-10-norway"}
|
||||
// ]
|
||||
// },
|
||||
]
|
||||
@@ -171,4 +171,23 @@ export const pathToMetadata = (path: string): navLink => {
|
||||
}
|
||||
|
||||
return foundEntry;
|
||||
}
|
||||
|
||||
export const getPaths = (
|
||||
currentEntries: navLink[] = siteLayout,
|
||||
paths: string[] = []
|
||||
): string[] => {
|
||||
let foundPaths: string[] = [];
|
||||
|
||||
for (const currentEntry of currentEntries) {
|
||||
if (currentEntry.children && currentEntry.children.length > 0) {
|
||||
foundPaths = [
|
||||
...foundPaths,
|
||||
...getPaths(currentEntry.children, [...paths, currentEntry.path || ""])
|
||||
]
|
||||
} else {
|
||||
foundPaths.push("/" + [...paths, currentEntry.path || ""].join("/"));
|
||||
}
|
||||
}
|
||||
return foundPaths.filter(path => path !== "/");
|
||||
}
|
||||
Reference in New Issue
Block a user