- the resources
+ Welcome to the TPH resources.
+
+ This is meant as a small knowledge base for commonly answered questions
+ on our Discord community,{" "}
+ The Programmer's Hangout.
+
+
)
}
diff --git a/src/utils/index.ts b/src/utils/index.ts
index a7a3fd2..0a9c680 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,4 +1,4 @@
-import { IFileOrFolder } from "../components/ResourcesSidebar/index"
+import { IFile, IFileOrFolder } from "../components/ResourcesSidebar/index"
export function traversePaths(
[head, ...tail]: string[],
@@ -22,3 +22,28 @@ export function traversePaths(
children: [traversePaths(tail, path)],
}
}
+
+export function traversePathsToFiles(
+ [head, ...tail]: string[],
+ basePath: string = "/resources",
+ depth: number = 0
+): IFileOrFolder {
+ const path = basePath + "/" + head + "/" + tail.join("/")
+
+ if (depth !== 0) {
+ // probably not more than one dot
+ const [name] = basePath.split(".")
+ return {
+ title: name,
+ type: "file",
+ path: basePath,
+ }
+ }
+
+ return {
+ title: head,
+ type: "folder",
+ path,
+ children: [traversePathsToFiles(tail, path, 1)],
+ }
+}