1 | # Entu SSG
|
2 |
|
3 | ## Benefits
|
4 |
|
5 | - Simple Pug (Jade), Markdown, Yaml static site generator.
|
6 | - Use Your favorite tools/editors.
|
7 | - Generate static HTML files from [Pug](https://pugjs.org) templates or [Markdown](https://en.wikipedia.org/wiki/Markdown).
|
8 | - Generate site CSS from [Stylus](http://stylus-lang.com) files.
|
9 | - Pass data to templates with [Yaml](http://yaml.org) files.
|
10 | - Use locale identificator in filenames to generate locale specific content.
|
11 | - ...
|
12 |
|
13 |
|
14 | ## Installation and usage
|
15 |
|
16 | 1. Download [latest build](https://github.com/entu/entu-ssg/releases/latest)
|
17 | 2. Run:
|
18 | ```
|
19 | ./build.js ./my-page/entu-ssg-config.yaml
|
20 | ```
|
21 |
|
22 |
|
23 | ### Configuration
|
24 |
|
25 | Sites build process is configurable by Yaml file and its path must be first argument for entu-ssg.js. Required parameters are:
|
26 |
|
27 | - __locales__ - List of locale folders to generate. You can put locale identificator to filename (like index.en.pug or data.et.yaml) for locale speciffic content.
|
28 | - __defaultLocale__ - If set, page paths in this locale will not get locale prefix (_/en/about_ will be just _/about_).
|
29 | - __source__ - Folder with source files (realtive to build config.yaml). Folders beginning with underscore are ignored.
|
30 | - __build__ - Folder to put generated HTML (realtive to build config.yaml).
|
31 | - __assets__ - Folder with static assets (JS, images, ...).
|
32 | - __protectedFromCleanup__ - List of paths what is not deleted if _build.sh_ is ran with _cleanup_ parameter. Relative to _build_ path.
|
33 | - __server.port__ - What port to use for serving on localhost.
|
34 | - __server.assets__ - Serving page in localhost will map this url to folder specified in _assets_ parameter.
|
35 | - __dev.aliases__ - Build pages aliases.
|
36 | - __dev.paths__ - List of (source) paths to build. Relative to _source_ path.
|
37 |
|
38 | ### Example build configuration file:
|
39 |
|
40 | ```
|
41 | locales:
|
42 | - en
|
43 | - et
|
44 | source: ./source
|
45 | build: ./build
|
46 | assets: ./assets
|
47 | protectedFromCleanup:
|
48 | - assets
|
49 | - index.html
|
50 | server:
|
51 | port: 4000
|
52 | assets: /assets/
|
53 | dev:
|
54 | aliases: true
|
55 | paths:
|
56 | - test/page1
|
57 | - test/page2
|
58 | ```
|
59 |
|
60 |
|
61 | ## Content
|
62 |
|
63 | ### Page content - index.pug
|
64 |
|
65 | Page content is generated from __index.pug__ file. All other files are ignored, but You can use those files for Pug [include](https://pugjs.org/language/includes.html)/[extends](https://pugjs.org/language/inheritance.html). You can put locale identificator to filename (like index.en.pug) for locale speciffic content.
|
66 |
|
67 | ### Page data and configuration - data.yaml
|
68 |
|
69 | To pass data to index.pug use __data.yaml__ file. This data is passed to index.pug in object named _self_ (To get property _text_ from data.yaml use _self.text_ in index.pug).
|
70 |
|
71 | You can put locale identificator to filename (like data.en.yaml) for locale speciffic content.
|
72 |
|
73 | Some page parameters will change how HTML is generated. Those are:
|
74 | - __disabled__ - If true, page will not be generated nor loaded to _self.otherLocales_ object.
|
75 | - __path__ - If set, it will override folder based path.
|
76 | - __aliases__ - List of path aliases. Will make redirekt urls to original path.
|
77 | - __data__ - Files to load data from. This data is passed to index.pug in object named _self.data_. You can use relative path (./ or ../). If used, it's relative to _data.yaml_ file. Root (/) path is Your source folder (set in _config.yaml_).
|
78 |
|
79 | ### Example page data.yaml:
|
80 |
|
81 | ```
|
82 | path: /testpage1
|
83 | aliases:
|
84 | - /test
|
85 | - /test123
|
86 | data:
|
87 | news: ./datafiles/news.yaml
|
88 | someOtherData:
|
89 | - A
|
90 | - B
|
91 | ```
|
92 |
|
93 | ### Page style - style.styl
|
94 |
|
95 | To generate page CSS use __.styl__ files. Global style.css is combined from all .styl files (from source folder) and saved to build's root folder (like /style.css).
|
96 |
|
97 | ### Page scripts - script.js
|
98 |
|
99 | To generate page JS use __.js__ files. Global script.js is combined from all .js files (from source folder) and saved to build's root folder (like /script.js).
|
100 |
|
101 | ## On build ...
|
102 |
|
103 | ### ... source folder like this ...
|
104 |
|
105 | ```
|
106 | - source
|
107 | |- _templates
|
108 | | |- layout.pug
|
109 | | |- mixins.pug
|
110 | | +- somescripts.js
|
111 | |
|
112 | |- testpage1
|
113 | | |- data.en.yaml
|
114 | | |- data.et.yaml
|
115 | | |- index.pug
|
116 | | +- style.et.styl
|
117 | |
|
118 | |- testpage2
|
119 | | |- index.en.pug
|
120 | | |- index.et.pug
|
121 | | |- data.yaml
|
122 | | +- testpage2en
|
123 | | |- index.en.pug
|
124 | | +- data.en.yaml
|
125 | |
|
126 | |- index.pug
|
127 | +- style.styl
|
128 | ```
|
129 |
|
130 | ### ... will be converted to build folder like this
|
131 |
|
132 | ```
|
133 | - build
|
134 | |- en
|
135 | | |- index.html
|
136 | | |- testpage1
|
137 | | | +- index.html
|
138 | | |
|
139 | | +- testpage2
|
140 | | |- index.html
|
141 | | +- testpage2en
|
142 | | +- index.html
|
143 | |
|
144 | |- et
|
145 | | |- index.html
|
146 | | |- testpage1
|
147 | | | +- index.html
|
148 | | |
|
149 | | +- testpage2
|
150 | | +- index.html
|
151 | |- script.js
|
152 | |- script.js.map
|
153 | |- style.css
|
154 | +- style.css.map
|
155 | ```
|
156 |
|
157 | [![npm version](https://badge.fury.io/js/entu-ssg.svg)](https://badge.fury.io/js/entu-ssg) [![Dependency Status](https://david-dm.org/entu/entu-ssg/status.svg)](https://david-dm.org/entu/entu-ssg) [![Codacy Badge](https://api.codacy.com/project/badge/grade/66531026074a471897b076fb91a74601)](https://www.codacy.com/app/argoroots/entu-ssg)
|