Skip to content

Commit

Permalink
feat: Added changelog page and version to footer
Browse files Browse the repository at this point in the history
  • Loading branch information
ripixel committed Jun 6, 2020
1 parent 3bbfe51 commit 08c2b9e
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 5 deletions.
35 changes: 35 additions & 0 deletions assets/styles/styles.css
Expand Up @@ -270,6 +270,31 @@ main.area {
white-space: nowrap;
}

main.changelog {
min-height: 0;
background: #fff;
color: #333;
}

main.changelog * {
text-transform: none;
}

main.changelog a {
color: #333;
border-bottom: 1px solid #333;
}

main.changelog a:hover {
color: #aaa;
border-bottom: 1px solid #aaa;
}

main.changelog section {
border-left: none;
padding-left: 0;
}

main.coding {
min-height: 0;
background: rgb(78, 0, 72);
Expand Down Expand Up @@ -356,6 +381,16 @@ footer .copy {
font-size: 0.8em;
}

footer .copy a {
color: #777;
border-bottom: 1px solid #777;
}

footer .copy a:hover {
color: #ccc;
border-bottom: 1px solid #ccc;
}

.flexme {
flex-wrap: wrap;
display: flex;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -5,8 +5,8 @@
"main": "index.js",
"scripts": {
"dev": "nodemon",
"build": "mkdir -p ./public && npm run build:css && npm run build:favicons && npm run build:pages && npm run build:images && npm run build:thoughts && npm run build:sitemap",
"build:dev": "mkdir -p ./public && npm run build:css && npm run build:pages && npm run build:images && npm run build:thoughts",
"build": "mkdir -p ./public && npm run build:css && npm run build:favicons && npm run build:pages && npm run build:images && npm run build:thoughts && npm run build:sitemap && npm run build:changelog",
"build:dev": "mkdir -p ./public && npm run build:css && npm run build:pages && npm run build:images && npm run build:thoughts && npm run build:changelog",
"build:pages": "ts-node ./scripts/generatePages",
"build:css": "cleancss -o ./public/styles.min.css ./assets/styles/*.css",
"build:favicons": "favicons-generate",
Expand All @@ -15,7 +15,7 @@
"build:changelog": "ts-node ./scripts/generateChangelog",
"build:thoughts": "mkdir -p ./public/thoughts && ts-node ./scripts/generateThoughts",
"release": "standard-version",
"rbp": "npm run release && npm run build &&"
"rp": "npm run release && git push --follow-tags origin master"
},
"repository": {
"type": "git",
Expand Down
18 changes: 18 additions & 0 deletions pages/changelog.html
@@ -0,0 +1,18 @@
<!DOCTYPE html>

<html lang="en">
{head.html}

<body>
{nav.html}

<main class="changelog article">
<p>What changes have happened to this site?</p>
<section class="area">
{changelog}
</section>
</main>

{footer.html}
</body>
</html>
37 changes: 37 additions & 0 deletions scripts/generateChangelog.ts
@@ -0,0 +1,37 @@
import * as fs from "fs";
import showdown from "showdown";

import findInDir from "./findInDir";

console.log("/// Beginning changelog generation");

const CHANGELOG_HTML_LOCATION = "./public/changelog.html";

const changelogMdContent = fs.readFileSync("./CHANGELOG.md", "utf8");
let changelogHtmlContent = fs.readFileSync(CHANGELOG_HTML_LOCATION, "utf8");

const mdConverter = new showdown.Converter();

const changelogContent = mdConverter.makeHtml(changelogMdContent);
changelogHtmlContent = changelogHtmlContent.replace(
"{changelog}",
changelogContent
);

fs.writeFileSync(CHANGELOG_HTML_LOCATION, changelogHtmlContent, "utf8");

const versionMatch = changelogMdContent.match(
/## ((0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?)/
);

const version =
versionMatch && versionMatch.length > 2 ? versionMatch[1] : "ER.RO.R";

const pages = findInDir("./public", ".html");

pages.forEach((page) => {
const pageContent = fs.readFileSync(page, "utf8");
fs.writeFileSync(page, pageContent.replace("{version}", version), "utf8");
});

console.log("/// Finished changelog generation");
3 changes: 3 additions & 0 deletions scripts/generatePages.ts
Expand Up @@ -27,6 +27,9 @@ pages.forEach((page) => {
case "coding":
description = "Shall we take a look at some projects I've done?";
break;
case "changelog":
description = "What changes have happened to this site?";
break;
default:
// do nothing - already set description for home/index
}
Expand Down
8 changes: 7 additions & 1 deletion scripts/generateSitemap.ts
Expand Up @@ -45,10 +45,16 @@ const generateUrlElement = (loc: string) => {

if (loc.indexOf("thoughts/") > -1) {
// is an article/subpage
prio = "0.5";
prio = "1";
changefreq = "yearly";
}

if (loc.indexOf("changelog") > 1) {
// it's the changelog
prio = "0.1";
changefreq = "weekly";
}

console.log(loc, prio, changefreq);

return {
Expand Down
4 changes: 3 additions & 1 deletion templates/footer.html
Expand Up @@ -46,5 +46,7 @@
</svg>
</a>
</div>
<p class="copy">&copy; 2020 James King</p>
<p class="copy">
<a href="/changelog.html">v{version}</a> &copy; 2020 James King
</p>
</footer>

0 comments on commit 08c2b9e

Please sign in to comment.