I'm creating a guide which will be a source of truth. I've got all my modules in a folder and all my page templates in another. I'm creating a page which will display the modules and templates. Whenever a new module or template is created it needs to be added straight to this page. I need the gulp task to automatically add the module to a json file which I then pull from.
1) Create gulp task that pulls files from src and populates json file ("modules-guide.json") the following details as an array: - Name (taken from the file name, removing the dashes and replacing it with spaces) - File name (same as file name minus the extension) - Id (same as file name minus extension)
2) Pull information from modules-guide.json to populate html file.
I've tried creating a gulp task which pulls the modules and outputs it into the modules-guide.json
The file structure:
//templates
+-- index.ejs
+-- aboutUs.ejs
+-- modules
| +-- header.ejs
+-- components
| +-- heading.ejs
| +-- buttons.ejs
import path from 'path'
import gulp from 'gulp'
const jsonGuideData = './src/content/modules-guide.json';
gulp.task('module-guide', function(){
gulp.src(path.join(src, 'templates/modules/**'))
.pipe(gulp.dest(path.join(src, 'content/modules-guide.json')));
});
I expect the output to be a page with modules that are automatically created when we create a new file. We don't want to manually add the files to the guide.