From ef9236f47a5225986faa1b5fed60d693b7cd76a7 Mon Sep 17 00:00:00 2001 From: Stephan Date: Thu, 21 Mar 2019 21:45:43 +0100 Subject: [PATCH] Created entry file switch Added checks for index.njk and data.json files to switch from demo file usage. To prevent override of default files. Updated explanation on demo entry page. --- gulpfile.js | 17 +++++++++++++---- source/screens/demo.njk | 16 ++++++++-------- source/templates/data.json | 26 ++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 source/templates/data.json diff --git a/gulpfile.js b/gulpfile.js index 0629a1e..05f94e4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,9 +2,10 @@ const hippie = { brand: 'hippie', jsFile: 'main', - jsonFile: 'db' + jsonFile: 'db', + index: 'demo.html', + data: 'demo/data.json' } - // Gulp requirements const { watch, series, parallel } = require('gulp'); const { src, dest } = require('gulp'); @@ -68,6 +69,14 @@ const output = { vendor: 'build/vendor' }; +//Check for index file and deactivate demo content +if (fs.existsSync('source/screens/index.*')){ + hippie.index = 'index.html'; +} +if (fs.existsSync('source/templates/data.json')){ + hippie.data = 'data.json'; +} + // Create tasks // Clean build folder @@ -99,7 +108,7 @@ function nunjucks() { return src(input.screens) .pipe(plumber()) .pipe(data(function() { - let data = JSON.parse(fs.readFileSync(input.demo.data)); + let data = JSON.parse(fs.readFileSync(input.templates +'/'+ hippie.data)); object = {hippie, data}; return object; })) @@ -115,7 +124,7 @@ function nunjucks() { // Serve files to the browser function serve(done) { server.init({ - index: "demo.html", + index: hippie.index, open: false, server: output.root }); diff --git a/source/screens/demo.njk b/source/screens/demo.njk index 42f8b9b..6d30899 100644 --- a/source/screens/demo.njk +++ b/source/screens/demo.njk @@ -14,10 +14,13 @@

This is {{hippie.brand | upper}}

You can start using it by replacing this file with your own index page.

-

To do this you need to open the file /gulpfile.js and comment out the line index: "demo.html",. Then you need to place your index file (index.njk) into the folder /source/pages.

-

For a very basic start you can make a copy of the demo page blank.njk. You can find it at /source/pages/demo.

-

The demo folder contains an overview of all elements and also examples for style combinations and even whole page layouts.
Follow the white rabbit.

-

Overview

+

To do this you need to create a file /index.njk inside the source/screens folder. You can also create a data.json file inside the source/templates folder as a data source for your nunjucks files.

+

For a very basic start you can make a copy of the demo page blank.njk. You can find it at /source/screens/demo.

+

The source/demo folder contains an overview of all HTML elements and also examples for CSS style combinations and even whole page layouts.
Follow the white rabbit.

+
+
  ()()
(..)
C(")(")
+

Overview

+
-
-
  ()()
(..)
C(")(")
-

Demo Pages

-
+

Demo Pages