Very nice! I've made some changes in my project, perhaps this is of any use to someone.
In the walkSync method I used the 'dir' parameter to replace pages/. This makes the method reusable for any other paths such as posts.
// ... not shown for brevityconstcleanFileName=filePath.substr(0,filePath.lastIndexOf('.')).replace(dir,'');// ... not shown for brevity
Also, by using an early return I filtered out any files that do not compile to an actual file:
// ... not shown for brevityfiles.forEach((file)=>{constpartialNextFile=/^_\w*/;// any filenames starting with _*constdynamicNextFile=/^\[(.*?)\]/;// any filenames between brackets [*]if(partialNextFile.test(file)||dynamicNextFile.test(file)){// skipreturn;}// ... not shown for brevity
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Very nice! I've made some changes in my project, perhaps this is of any use to someone.
In the walkSync method I used the 'dir' parameter to replace
pages/
. This makes the method reusable for any other paths such as posts.Also, by using an early return I filtered out any files that do not compile to an actual file: