break down foldername into subpaths

This commit is contained in:
geoffrey45
2022-05-26 23:59:47 +03:00
parent b02cdc22eb
commit 47eb5b49cd
5 changed files with 140 additions and 16 deletions
+17
View File
@@ -0,0 +1,17 @@
import { subPath } from "@/interfaces";
/**
* Breaks a path into sub-paths.
* @param {string} paths to break into subpaths
* @returns {subPath[]} an array of subpaths
*/
export default function createSubPaths(paths: string | string[]): subPath[] {
const pathlist = (paths as string).split("/");
pathlist.shift();
const subPaths = pathlist.map((path, index) => {
return { name: path, path: pathlist.slice(0, index + 1).join("/") };
});
return subPaths;
}
+11
View File
@@ -24,3 +24,14 @@ export enum ContextSrc {
AHeader = "AHeader",
FHeader = "FHeader"
}
export enum Routes {
home = "Home",
folder = "FolderView",
playlists = "Playlists",
playlist = "PlaylistView",
albums = "AlbumsView",
album = "AlbumView",
artists = "ArtistsView",
settings = "SettingsView",
}