Skip to content

Commit

Permalink
feat: Automatically generate copy date and age at build
Browse files Browse the repository at this point in the history
  • Loading branch information
ripixel committed Jun 14, 2020
1 parent 842b9e1 commit 748edbb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pages/profile.html
Expand Up @@ -10,7 +10,7 @@
<section class="area">
<h3>So who am I?</h3>
<p>
I&apos;m <span class="em">James King</span>, a 27 year old Software
I&apos;m <span class="em">James King</span>, a {age} year old Software
Engineer from Lincolnshire, who has an affinity for Coca-Cola, bacon,
and being pretty bad at boardgames despite my intense love of them.
You want some more info?
Expand Down
10 changes: 9 additions & 1 deletion scripts/generatePages.ts
Expand Up @@ -45,7 +45,15 @@ pages.forEach((page) => {
templateContents
)
.replace(/{subpage}/g, '')
.replace(/{description}/g, description);
.replace(/{description}/g, description)
.replace(
/{age}/g,
new Number(
(new Date().getTime() - new Date('1992-05-21').getTime()) /
31536000000
).toFixed(0)
)
.replace(/{year}/g, new Date().getFullYear().toString());
});

fs.writeFileSync(page.replace('pages/', 'public/'), pageContents, 'utf8');
Expand Down
2 changes: 1 addition & 1 deletion templates/footer.html
Expand Up @@ -47,6 +47,6 @@
</a>
</div>
<p class="copy">
<a href="/changelog.html">v{version}</a> &copy; 2020 James King
<a href="/changelog.html">v{version}</a> &copy; {year} James King
</p>
</footer>

0 comments on commit 748edbb

Please sign in to comment.