Skip to content

Commit cea81c3

Browse files
committedJan 7, 2022
Code style cleanup, node package update, and adding formatting.
1 parent f4f9501 commit cea81c3

13 files changed

+2830
-546
lines changed
 

‎_data/gear.js

+31-19
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
1-
const CSVToJSON = require('csvtojson')
1+
const CSVToJSON = require('csvtojson');
22

33
const compare = (a, b) => {
4-
a.Priority = (!a.Priority) ? a.Priority = 9000 : parseInt(a.Priority)
5-
b.Priority = (!b.Priority) ? b.Priority = 9000 : parseInt(b.Priority)
6-
if (a.Priority > b.Priority) return 1
7-
if (a.Priority < b.Priority) return -1
8-
if (a.Title > b.Title) return 1
9-
if (a.Title < b.Title) return -1
10-
return 0
11-
}
4+
a.Priority = (a.Priority) ? Number.parseInt(a.Priority, 10) : a.Priority = 9000;
5+
b.Priority = (b.Priority) ? Number.parseInt(b.Priority, 10) : b.Priority = 9000;
6+
if (a.Priority > b.Priority) {
7+
return 1;
8+
}
9+
10+
if (a.Priority < b.Priority) {
11+
return -1;
12+
}
13+
14+
if (a.Title > b.Title) {
15+
return 1;
16+
}
17+
18+
if (a.Title < b.Title) {
19+
return -1;
20+
}
21+
22+
return 0;
23+
};
1224

1325
module.exports = function () {
14-
return new Promise(async (resolve, reject) => {
15-
try {
16-
const gears = await CSVToJSON().fromFile('_data/gear.csv')
17-
const gearsSorted = gears.sort(compare)
18-
return resolve(gearsSorted)
19-
} catch (err) {
20-
console.error('error while loading gears CSV file: ', err)
21-
}
22-
})
23-
}
26+
return new Promise(async (resolve, reject) => {
27+
try {
28+
const gears = await CSVToJSON().fromFile('_data/gear.csv');
29+
const gearsSorted = gears.sort(compare);
30+
return resolve(gearsSorted);
31+
} catch (error) {
32+
console.error('error while loading gears CSV file:', error);
33+
}
34+
});
35+
};

‎_data/git.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const git = require('async-git');
22

3-
module.exports = async function() {
4-
return {
5-
commitsha: await git.short,
6-
curbranch: await git.branch,
7-
commitdate: await git.date,
8-
origin: await git.origin,
9-
}
10-
}
3+
module.exports = async function () {
4+
return {
5+
commitsha: await git.short,
6+
curbranch: await git.branch,
7+
commitdate: await git.date,
8+
origin: await git.origin,
9+
};
10+
};

‎_data/global.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const moment = require('moment')
1+
const moment = require('moment');
22

33
module.exports = {
4-
dateReadable: (date) => moment(date).format('MMMM Do, YYYY'),
5-
dateReadableShort: (date) => moment(date).format('Do MMM YYYY'),
6-
dateHtml: (date) => moment(date).toISOString(),
7-
}
4+
dateReadable: date => moment(date).format('MMMM Do, YYYY'),
5+
dateReadableShort: date => moment(date).format('Do MMM YYYY'),
6+
dateHtml: date => moment(date).toISOString(),
7+
};

‎_data/layout.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = "page.pug"
1+
module.exports = 'page.pug';

‎_data/meta.js

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
const path = require("path");
1+
const process = require('process');
2+
const path = require('path');
23

34
module.exports = {
4-
siteTitle: "Chris Spiegl — Content Creator, World Traveler, and Consultant",
5-
siteName: "ChrisSpiegl.com",
6-
url: "https://ChrisSpiegl.com",
7-
imageResizer: (width, height, origin) => {
8-
const ext = path.extname(origin);
9-
const base = path.basename(origin, ext);
10-
const dir = path.dirname(origin);
11-
const imagePath = path.join(dir, `${base}-${width}w${ext}`);
12-
return imagePath;
13-
},
14-
authorEmail: "chris@chrisspiegl.com",
15-
build: {
16-
env: process.env.ELEVENTY_ENV || process.env.NODE_ENV || 'development',
17-
timestamp: new Date(),
18-
},
5+
siteTitle: 'Chris Spiegl — Content Creator, World Traveler, and Consultant',
6+
siteName: 'ChrisSpiegl.com',
7+
url: 'https://ChrisSpiegl.com',
8+
imageResizer: (width, height, origin) => {
9+
const ext = path.extname(origin);
10+
const base = path.basename(origin, ext);
11+
const dir = path.dirname(origin);
12+
const imagePath = path.join(dir, `${base}-${width}w${ext}`);
13+
return imagePath;
14+
},
15+
authorEmail: 'chris@chrisspiegl.com',
16+
build: {
17+
env: process.env.ELEVENTY_ENV || process.env.NODE_ENV || 'development',
18+
timestamp: new Date(),
19+
},
1920
};

‎_data/nomadlist.js

+25-24
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,28 @@
1-
var axios = require('axios')
1+
const axios = require('axios');
22

3-
module.exports = async function() {
4-
const url = 'https://nomadlist.com/@ChrisSpiegl'
5-
try {
6-
const { data } = await axios.get(`${url}?format=json`)
3+
module.exports = async function () {
4+
const url = 'https://nomadlist.com/@ChrisSpiegl';
5+
try {
6+
const {data} = await axios.get(`${url}?format=json`);
77

8-
data.location.now.string = data.location.now.city == null ? 'Unknown' : `${data.location.now.city}, ${data.location.now.country}`
9-
data.location.next.string = data.location.next.city == null ? 'Unknown' : `${data.location.next.city}, ${data.location.next.country}`
8+
data.location.now.string = data.location.now.city === null ? 'Unknown' : `${data.location.now.city}, ${data.location.now.country}`;
9+
data.location.next.string = data.location.next.city === null ? 'Unknown' : `${data.location.next.city}, ${data.location.next.country}`;
1010

11-
let ret = {
12-
data,
13-
url,
14-
now: data.location.now,
15-
next: data.location.next,
16-
}
17-
return ret
18-
} catch (error) {
19-
console.log(error);
20-
}
21-
return {
22-
data: {},
23-
url,
24-
now: 'Unknown',
25-
next: 'Unknown',
26-
}
27-
}
11+
const returnValue = {
12+
data,
13+
url,
14+
now: data.location.now,
15+
next: data.location.next,
16+
};
17+
return returnValue;
18+
} catch (error) {
19+
console.log(error);
20+
}
21+
22+
return {
23+
data: {},
24+
url,
25+
now: 'Unknown',
26+
next: 'Unknown',
27+
};
28+
};

‎_data/qrcode.js

+40-40
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
const QRCode = require('qrcode')
2-
const mkdirp = require("mkdirp")
1+
const QRCode = require('qrcode');
2+
const mkdirp = require('mkdirp');
33

44
module.exports = async () => {
5-
const coins = {
6-
'btc': {
7-
name: 'Bitcoin',
8-
addr: `bc1qcnjmuyr3a0ysejqnzwtu0dylsyt3w7hggwa49x`,
9-
link: `bitcoin:bc1qcnjmuyr3a0ysejqnzwtu0dylsyt3w7hggwa49x?label=Donation&message=Thank%20You%21`,
10-
},
11-
'ltc': {
12-
name: 'Litecoin',
13-
addr: `ltc1q2d3gqjn9y5evh0uvfesgqnqxwguwky78448aw7`,
14-
link: `litecoin:ltc1q2d3gqjn9y5evh0uvfesgqnqxwguwky78448aw7?label=Donation&message=Thank%20You%21`,
15-
},
16-
'doge': {
17-
name: 'Dogecoin',
18-
addr: `DRZVXSnWM9BEL9FFLdE2qmUDBpbWLQC4Cp`,
19-
link: `DRZVXSnWM9BEL9FFLdE2qmUDBpbWLQC4Cp?label=Donation&message=Thank%20You%21`,
20-
},
21-
'xlm': {
22-
name: 'Stellar Lumens',
23-
addr: `GADRZ6G2BXHUJGJQUNR4L6KK3RUPLT3AIV2CP6JQ37ICODJP4FMW7T5T`,
24-
link: `GADRZ6G2BXHUJGJQUNR4L6KK3RUPLT3AIV2CP6JQ37ICODJP4FMW7T5T?label=Donation&message=Thank%20You%21`,
25-
},
26-
'bat': {
27-
name: 'Basic Attention Token',
28-
addr: `0x5696005CA7F60F86F69bdBd897987c410D34398F`,
29-
link: `0x5696005CA7F60F86F69bdBd897987c410D34398F?label=Donation&message=Thank%20You%21`,
30-
},
31-
}
5+
const coins = {
6+
btc: {
7+
name: 'Bitcoin',
8+
addr: 'bc1qcnjmuyr3a0ysejqnzwtu0dylsyt3w7hggwa49x',
9+
link: 'bitcoin:bc1qcnjmuyr3a0ysejqnzwtu0dylsyt3w7hggwa49x?label=Donation&message=Thank%20You%21',
10+
},
11+
ltc: {
12+
name: 'Litecoin',
13+
addr: 'ltc1q2d3gqjn9y5evh0uvfesgqnqxwguwky78448aw7',
14+
link: 'litecoin:ltc1q2d3gqjn9y5evh0uvfesgqnqxwguwky78448aw7?label=Donation&message=Thank%20You%21',
15+
},
16+
doge: {
17+
name: 'Dogecoin',
18+
addr: 'DRZVXSnWM9BEL9FFLdE2qmUDBpbWLQC4Cp',
19+
link: 'DRZVXSnWM9BEL9FFLdE2qmUDBpbWLQC4Cp?label=Donation&message=Thank%20You%21',
20+
},
21+
xlm: {
22+
name: 'Stellar Lumens',
23+
addr: 'GADRZ6G2BXHUJGJQUNR4L6KK3RUPLT3AIV2CP6JQ37ICODJP4FMW7T5T',
24+
link: 'GADRZ6G2BXHUJGJQUNR4L6KK3RUPLT3AIV2CP6JQ37ICODJP4FMW7T5T?label=Donation&message=Thank%20You%21',
25+
},
26+
bat: {
27+
name: 'Basic Attention Token',
28+
addr: '0x5696005CA7F60F86F69bdBd897987c410D34398F',
29+
link: '0x5696005CA7F60F86F69bdBd897987c410D34398F?label=Donation&message=Thank%20You%21',
30+
},
31+
};
3232

33-
for (const coin of Object.keys(coins)) {
34-
const exportPath = `_site`
35-
const folderPath = `/assets/images/qrcodes`
36-
mkdirp.sync(exportPath + folderPath)
37-
coins[coin].filepath = `${folderPath}/${coin}-${coins[coin].addr}.svg`
38-
await QRCode.toFile(`${exportPath}${coins[coin].filepath}`, coins[coin].link)
39-
coins[coin].rendered = `!!! ${coins[coin].name} — $${coin.toUpperCase()}: \`${coins[coin].addr}\`
33+
for (const coin of Object.keys(coins)) {
34+
const exportPath = '_site';
35+
const folderPath = '/assets/images/qrcodes';
36+
mkdirp.sync(exportPath + folderPath);
37+
coins[coin].filepath = `${folderPath}/${coin}-${coins[coin].addr}.svg`;
38+
await QRCode.toFile(`${exportPath}${coins[coin].filepath}`, coins[coin].link);
39+
coins[coin].rendered = `!!! ${coins[coin].name} — $${coin.toUpperCase()}: \`${coins[coin].addr}\`
4040
![QR Code for $${coin.toUpperCase()} address](${coins[coin].filepath})
41-
!!!`
42-
}
41+
!!!`;
42+
}
4343

44-
return coins
45-
}
44+
return coins;
45+
};

0 commit comments

Comments
 (0)
Failed to load comments.