Tweaked some things.
This commit is contained in:
parent
e61de3e3ab
commit
bae9e71800
@ -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'))
|
||||
}
|
||||
|
||||
|
4
index.js
4
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 = {
|
||||
|
@ -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"
|
||||
},
|
||||
|
28
theme/helper.js
Normal file
28
theme/helper.js
Normal file
@ -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
|
||||
};
|
1
theme/pug/test.pug
Normal file
1
theme/pug/test.pug
Normal file
@ -0,0 +1 @@
|
||||
h1=helper.formatdate(new Date('2020-01-02'))
|
@ -0,0 +1,3 @@
|
||||
.foo {
|
||||
background-color: black;
|
||||
}
|
@ -1 +1,5 @@
|
||||
@charset "UTF-8";
|
||||
|
||||
.foo{
|
||||
background-color: black;
|
||||
}
|
@ -4,5 +4,6 @@ html(lang="en")
|
||||
meta(charset="utf-8")
|
||||
style
|
||||
include styles.css
|
||||
title=`Resume ${resume.basics.name}`
|
||||
title=`${resume.basics.name} - Resume`
|
||||
body
|
||||
include pug/test
|
Loading…
Reference in New Issue
Block a user