From bae9e71800fd16aea316bdc179406f4d9b90ce5f Mon Sep 17 00:00:00 2001 From: Thomas Cole Date: Wed, 3 May 2023 16:44:33 -0400 Subject: [PATCH] Tweaked some things. --- gulpfile.js | 3 ++- index.js | 4 +++- package.json | 2 +- theme/helper.js | 28 ++++++++++++++++++++++++++++ theme/pug/test.pug | 1 + theme/styles.css | 3 +++ theme/styles.scss | 6 +++++- theme/template.pug | 5 +++-- 8 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 theme/helper.js create mode 100644 theme/pug/test.pug diff --git a/gulpfile.js b/gulpfile.js index ea1a507..608f00e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -3,6 +3,7 @@ const pug = require('gulp-pug') const sass = require('gulp-sass')(require('sass')) const bs = require('browser-sync').create() const fs = require('fs') +const helper = require('./theme/helper.js'); function css () { return src('./theme/styles.scss') @@ -14,7 +15,7 @@ function html () { const resume = JSON.parse(fs.readFileSync('./resume.json', 'utf-8')) return src('./theme/template.pug') - .pipe(pug({ data: { resume } })) + .pipe(pug({ data: { resume, helper } })) .pipe(dest('./public')) } diff --git a/index.js b/index.js index 277dc22..8dda39a 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,10 @@ const pug = require('pug'); const path = require('path'); +const helper = require('./theme/helper') const render = (resume) => pug.renderFile(path.join(__dirname, 'theme', 'template.pug'),{ - resume + resume, + helper }) module.exports = { diff --git a/package.json b/package.json index d52e3a6..faf8eb9 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "dev": "resume serve --theme .", + "dev": "gulp", "resume": "resume", "build": "mkdir -p out && resume export out/resume.pdf && resume export out/resume.html" }, diff --git a/theme/helper.js b/theme/helper.js new file mode 100644 index 0000000..512e984 --- /dev/null +++ b/theme/helper.js @@ -0,0 +1,28 @@ +const validArray = (array) => array !== undefined && array.length > 0; + +const formatdate = (date) => { + const monthNames = [ + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December", + ]; + const monthIndex = date.getMonth(); + const year = date.getFullYear(); + + return `${monthNames[monthIndex]} ${year}`; +} + + +module.exports = { + validArray, + formatdate +}; diff --git a/theme/pug/test.pug b/theme/pug/test.pug new file mode 100644 index 0000000..e23bb20 --- /dev/null +++ b/theme/pug/test.pug @@ -0,0 +1 @@ +h1=helper.formatdate(new Date('2020-01-02')) \ No newline at end of file diff --git a/theme/styles.css b/theme/styles.css index e69de29..c656f8b 100644 --- a/theme/styles.css +++ b/theme/styles.css @@ -0,0 +1,3 @@ +.foo { + background-color: black; +} \ No newline at end of file diff --git a/theme/styles.scss b/theme/styles.scss index 03bb363..64af3fa 100644 --- a/theme/styles.scss +++ b/theme/styles.scss @@ -1 +1,5 @@ -@charset "UTF-8"; \ No newline at end of file +@charset "UTF-8"; + +.foo{ + background-color: black; +} \ No newline at end of file diff --git a/theme/template.pug b/theme/template.pug index c612fcc..afcb3b5 100644 --- a/theme/template.pug +++ b/theme/template.pug @@ -4,5 +4,6 @@ html(lang="en") meta(charset="utf-8") style include styles.css - title=`Resume ${resume.basics.name}` - body \ No newline at end of file + title=`${resume.basics.name} - Resume` + body + include pug/test \ No newline at end of file