2018-08-12 01:41:11 +00:00
|
|
|
# Static site generator
|
|
|
|
|
2018-08-13 04:12:18 +00:00
|
|
|
## Overview
|
|
|
|
|
2018-08-12 01:41:11 +00:00
|
|
|
This folder contains the template files needed to generate the static site for
|
|
|
|
this repo ( https://remoteintech.company/ ).
|
|
|
|
|
|
|
|
The code that parses the site's data from the Markdown files in this repository
|
|
|
|
is located in `bin/build-site.js` and `lib/index.js`.
|
|
|
|
|
2021-08-05 15:49:28 +00:00
|
|
|
On each new change to `main` or to a GitHub pull request, if there are no
|
2018-08-12 01:41:11 +00:00
|
|
|
data validation errors, the site is built and deployed to Netlify (the domain
|
2021-08-05 15:49:28 +00:00
|
|
|
mentioned above for the `main` branch, or a temporary subdomain for pull
|
2018-08-12 01:41:11 +00:00
|
|
|
requests).
|
|
|
|
|
|
|
|
The static site uses a layout and CSS copied from
|
|
|
|
https://blog.remoteintech.company/ which is a site hosted on WordPress.com, and
|
|
|
|
the site builder code uses
|
|
|
|
[`swig`](https://github.com/node-swig/swig-templates)
|
|
|
|
as an HTML templating engine.
|
|
|
|
|
2018-08-13 04:12:18 +00:00
|
|
|
## Development
|
|
|
|
|
|
|
|
If you submit any changes as a pull request, GitHub and Netlify will
|
|
|
|
automatically validate, build, and deploy a preview of the site for you.
|
|
|
|
|
|
|
|
For longer-running or more complicated changes, though, it can be useful to run
|
|
|
|
the site locally. To make this work, you should be using the version of
|
|
|
|
Node.js specified in the `.nvmrc` file. Other versions may work but have not
|
|
|
|
been tested.
|
|
|
|
|
|
|
|
Run `npm install` to install dependencies.
|
|
|
|
|
|
|
|
Then run `npm start` to build and serve the site locally.
|
|
|
|
|
|
|
|
You can also use `nodemon` to automatically rebuild and reload the site when
|
|
|
|
you make changes:
|
2018-08-12 01:41:11 +00:00
|
|
|
|
|
|
|
```sh
|
2018-08-13 04:12:18 +00:00
|
|
|
npm install -g nodemon
|
|
|
|
nodemon bin/serve-site.js
|
2018-08-12 01:41:11 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
If you just want the data structure used to build the site, you can do this:
|
|
|
|
|
|
|
|
```js
|
|
|
|
~/code/remote-jobs $ node
|
|
|
|
> const { parseFromDirectory } = require( './lib' );
|
|
|
|
undefined
|
|
|
|
> const data = parseFromDirectory( '.' );
|
|
|
|
undefined
|
|
|
|
> Object.keys( data );
|
|
|
|
[ 'ok',
|
|
|
|
'profileFilenames',
|
|
|
|
'profileHeadingCounts',
|
|
|
|
'companies',
|
|
|
|
'readmeContent' ]
|
|
|
|
> Object.keys( data.companies[ 0 ] )
|
|
|
|
[ 'name',
|
|
|
|
'isIncomplete',
|
|
|
|
'websiteUrl',
|
|
|
|
'websiteText',
|
|
|
|
'shortRegion',
|
|
|
|
'linkedFilename',
|
|
|
|
'profileContent' ]
|
|
|
|
...
|
|
|
|
```
|