tableflip/brandnewweddings

Name: brandnewweddings

Owner: TABLEFLIP

Description: :wedding: :robot: Website for brandnewweddings.co.uk

Created: 2016-04-06 09:41:14.0

Updated: 2016-11-29 08:03:49.0

Pushed: 2017-08-21 16:01:06.0

Homepage: http://www.brandnewweddings.co.uk

Size: 8113

Language: HTML

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

br&newweddings

Website for http://brandnewweddings.co.uk

Getting started

With node and npm installed:

install
start

This project uses npm scripts to build the site to the dist directory.

Helpers

Any module dropped into the helpers folder will be passed in the locals to all templates, with the obvious camel-case conversion (i.e. is-equal would be available as isEqual).

Declaring schemas

Fields in a content.json or facts.json which do not have a declared type in the corresponding schema.json are assumed to be of type text. The available types are:

If validation beyond that which is built in for these fields is required, it can be supplied in a validation key in the schema.json:


xampleField": {
"type": "text",
"validation": {
  "format": "uri"  
}
  

Available validation options are as per JSON-schema and can be found here.

Regex validation

JSON-schema regex patterns only allow a subset of those available in Javascript - for example, periods will match the period character rather than any character. Full details can be found under the pattern section here.

Defining collections

A collection (array of objects) is declared in the appropriate schema.json as a one-element array containing the declaration object rather than the object itself. Within this single object, declarations are as they would be for any other field. For example:


arousel": [{
"title": {
  "type": "text",
  "default": "New entry"
 },
"image": {
  "type": "img",
  "default": "http://placehold.it/350x150"
},
"link": {
  "type": "text",
  "default": "http://example.com",
  "validation": {
    "pattern": "^(https?://)?([0-9a-z.-]+).([a-z.]{2,6})([/[0-9][a-z].-]*)*/?$"  
  }
}


Note that in a collection every field requires a default to be set for the client to be able to add new items.

Collections which define sub-pages

Collections can be used to define subpages, so that the build process will provide a separate page in the same folder as the parent page for each item in a collection. To achieve this, you need to add the following key to the package.json:

Pages": {
y-page": {
"field": "subPages",
"slugFrom": "title",
"template": "subpage"


Each key in subPages should correspond to the page which contains the collection in question and under which the sub-pages will live.

The parent page template will receive the same content it would have otherwise, but each entry in the given collection will have _slug and _index values attached to it for easy routing.

For the child page template (either index.jade or the supplied alternative), the contents local is exactly as per the parent, but with an additional _entry field containing the contents of the specific entry (including _slug and _index).


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.