static-sites-builder
v1.0.5
Published
Node JS script for build static websites.
Downloads
1
Readme
Static site builder
This project is a static site builder It's built using just HTML and CSS. [email protected] is used for parsing HTML, so Handlebars features can be used.
Steps to build a project with static-sites-builder
mkdir my-fancy-static-website
cd my-fancy-static-website
npm init --y
npm i static-sites-builder
- Create an
html
file you wanna use. Eg:index.html
- Create a
scss
file. Eg:main.scss
- Create a json file for every language you wanna translate your site into (Eg: src/assets/en.json)
- Create an .env file with the following environment props (see .env.example for reference):
html
= Absolute path to your .html file (Eg: src/index.html)scss
= Absolute path to your .scss file (Eg: src/styles/main.scss)languages
= List of the languages you wanna translate your site into (Eg: ['es', 'en', 'ca']). For each of them anhtml
file will be generated.translations
= Path of the translations file (Eg: src/assets/i18n)
- Add the following script to your package.json scripts
"build": "build-site"
- Run
npm run build
- Check your the
dist
directortyat my-fancy-static-website
directory.
Translations files format:
Example of an es.json
translations file to translate into Spanish.
These 3 properties need to be in translations objects in order to build your site successfully, since they're used in the build process:
{
"meta_description": "",
"meta_keywords": "",
"title": ""
}
{
"hello":"Hola!"
}
Use of translations objects in HTML files.
Since the project is using Handlebars for managing translations, you just need to use it this way. It will be translated in build time.
Eg:
<p> {{ hello }} </p>