Tweaked some things.

This commit is contained in:
Thomas Cole 2023-05-03 16:44:33 -04:00
parent e61de3e3ab
commit bae9e71800
8 changed files with 46 additions and 6 deletions

View File

@ -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'))
}

View File

@ -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 = {

View File

@ -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
View 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
View File

@ -0,0 +1 @@
h1=helper.formatdate(new Date('2020-01-02'))

View File

@ -0,0 +1,3 @@
.foo {
background-color: black;
}

View File

@ -1 +1,5 @@
@charset "UTF-8";
@charset "UTF-8";
.foo{
background-color: black;
}

View File

@ -4,5 +4,6 @@ html(lang="en")
meta(charset="utf-8")
style
include styles.css
title=`Resume ${resume.basics.name}`
body
title=`${resume.basics.name} - Resume`
body
include pug/test