1.0.5 • Published 4 years ago
static-sites-builder v1.0.5
Static site builder
This project is a static site builder It's built using just HTML and CSS. Handlebars@4.7.7 is used for parsing HTML, so Handlebars features can be used.
Steps to build a project with static-sites-builder
mkdir my-fancy-static-websitecd my-fancy-static-websitenpm init --ynpm i static-sites-builder- Create an
htmlfile you wanna use. Eg:index.html - Create a
scssfile. 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 anhtmlfile 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
distdirectortyat my-fancy-static-websitedirectory.
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>