Reading directories recursivly is not the problem. There are many good libraries for it, for instance recursive-readdir.
I am searching for a solution to extract only the folder structure without any files etc.
Example folder structure:
src/app/_content
├── contact.md
├── disclaimer.md
├── imprint.md
├── index.md
├── news.md
├── vita.md
└── work
├── drawing
│ └── Z-WV-2018-001
│ ├── index.md
│ └── Z-WV-2018-001-0.jpeg
└── sculpture
└── EMPTY DIRECTORY
The wished output is an array like that:
const dirs = [
'work',
'work/drawing',
'work/sculpture'
]
Further Information: The following part is not explicitly part of that question. This will be an additional part for a better understand of the problem deep in the back of my brain.
This should not be that hard, but in addition I will need to extract in the second step an object like this:
const files = [
'content.md',
'disclaimer.md',
'imprint.md',
'index.md',
'news.md',
'vita.md',
{
'work': [
{
'drawing': [
{
'Z-WV-2018-001': [
'index.md',
'Z-WV-2018-001-0.jpeg'
],
},
{
'sculpture': []
}
]
}
]
}
]
dirs
will be needed for a browser application to know the pathes to the files. files
will be neded to get the corresponding files out of the directories.
For clarification, I am building a static page generator with Angular 6 and it is not possible to read client-sidely the folder structure. Therefore it is necessary to compile that structure and put it with an nodejs script into the published folder. So Angular will know where to look for that files.
Please write a comment, if you need more clarification. I just wanted to be exact as possible.