Website for The United Nations Global Goals for Sustainable Development
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin Initial commit Sep 28, 2018
lib Initial commit Sep 28, 2018
.babelrc Initial commit Sep 28, 2018
.editorconfig Initial commit Sep 28, 2018
.gitignore Initial commit Sep 28, 2018
README.md Initial commit Sep 28, 2018
index.js Initial commit Sep 28, 2018
package-lock.json Initial commit Sep 28, 2018
package.json Initial commit Sep 28, 2018
postcss.config.js Initial commit Sep 28, 2018

README.md

The Global Goals

Website GitHub tag style

Screenshot

Website for The United Nations Global Goals for Sustainable Development www.globalgoals.org

Setup

The application requires Node.js version 7 or later. Start with installing all dependencies by running the following command:

$ npm install

Environment variables

The application (both server and front end) depend on a set of environment variables. Define them in a .env file in the project root. The following command will generate a template for you which you to populate with secret keys and whatnot:

$ npm run setup

Start the server

During development use the restart script which loads the variables in the .env file, before starting the server. The server watches for file changes and restarts when needed.

$ npm restart

Technologies

The stack consists of a Node server running Koa and a front end built with Choo. Content is being fetched from the headless CMS Prismic.io.

Routing to and rendering views are all handled by Choo, the server only fetches content and caches the response.

Koa

Koa is a small framework for node which uses the new async/await syntax of ES2017. Just like most other popular web frameworks, Koa relies on middleware that intercepts and handles requests before (optionally) falling through to the next middleware. With Promises and the new async/await syntax this makes for building very lean and expressive applications.

Choo

Choo is a front-end framework for authoring websites and apps using standard JavaScript syntax and APIs. Templates are defined in JavaScript files as template literals and transformed to actual DOM nodes. The generated tree is then compared with and morphed into the real DOM tree updating where needed, much like React, just without the virtual DOM-part.

Note: Choo is currently exploring ways to incorporate components at the framework level. A preview of the proposed solution is implemented in this application.

SUIT CSS

The CSS is written and organized following the SUIT CSS principles. The source is then processed with a few postcss plugins.

Build and deploy

When building the application, take care to update the version field in package.json. The version number is used for breaking cache and ensuring that clients are receiving up to date assets. Npm has a version command that does just this, commits it and generates a git tag.

$ npm version 2.1.0

To build and minify the client application and styles run the build command. The build script will try and load the local .env file so make sure to define (overwriting) the appropriate variables before executing the script.

$ NODE_ENV=production npm run build

The application is built for running on Now but is in no way required to. Any server with node installed should be able to build and host the application.

License

Creative Commons Attribution 3.0 Unported (CC-BY)