In this project we'll build a static site generator with few features that can build static sites like building a simple portfolio-like site.
First install Node js : https://nodejs.org/dist/v16.18.0/node-v16.18.0-x64.msi
Install it with default settings
Watch Node js tutorial: https://www.youtube.com/watch?v=gFSXD7mOrFs
public/
src/
assets/
data/
pages/
partials/
layout.ejs
site.config.js
- public: where the generated site will be.
- src: the source of the site contents.
src/assets: contains CSS, JS, images, etc.
src/data: contains JSON data.
src/pages: are the templates that will be rendered to HTML. The directory structure found here will be replicated in the resulting site.
src/partials: contains our reusable partials.
src/layout.ejs: contains the common page structure, with a special placeholder, where the contents of each page will be inserted. - site.config.js: it just exports an object that will be available in the page templates.
Why EJS templates? Because EJS is simple. There is no new template language to learn. It’s just JavaScript embedded in HTML.
For this basic feature set we only need three dependencies:
- ejs
Compile our templates to HTML. - fs-extra
Adds new functions to Node’s native file-system module (fs) and add promise support for the existing ones. - glob
Recursively read a directory, returning an array with all files that match an specified pattern.
- Go to Pull Request section on your forked repository
- Now click on New Pull Request button (green colour) on right of your screen
- Now click on create pull request button on the right side
- Add the title of your pull request(specific to changes or updates you made) and explain it in the comment section
- Now click on Create Pull request
More Updates coming soon...
Happy learning, I hope you learned something new.
GitHub ref GitHub ref GitHub ref