Skip to content

Commit 94e6441

Browse files
committed
Website deployment
1 parent 8ed9e6e commit 94e6441

File tree

5 files changed

+102
-51
lines changed

5 files changed

+102
-51
lines changed

.github/workflows/deploy-website.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ jobs:
2727

2828
- name: Install dependencies
2929
run: |
30-
npm install -g marked
31-
npm install -g html-minifier-terser
30+
cd website
31+
npm install
32+
cd ..
3233
3334
- name: Build website
3435
run: |

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@
1515
# Misc
1616
.DS_Store
1717
Thumbs.db
18+
19+
# Node
20+
node_modules
21+
build
22+
npm-debug.log
23+
.env
24+
.DS_Store

website/build.js

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,56 @@
11
// website-src/build.js
22
const fs = require("fs");
33
const path = require("path");
4-
const { marked } = require("marked");
5-
6-
// Read README.md
7-
const readmeContent = fs.readFileSync("README.md", "utf8");
8-
9-
// Read HTML template
10-
const template = fs.readFileSync("website/index.html", "utf8");
11-
12-
// Configure marked for GitHub-style rendering
13-
marked.setOptions({
14-
gfm: true,
15-
breaks: true,
16-
headerIds: true,
17-
mangle: false,
18-
});
19-
20-
// Convert markdown to HTML
21-
const htmlContent = marked(readmeContent);
22-
23-
// Read specs files
24-
const specsDir = "docs/specs";
25-
const specsFiles = fs
26-
.readdirSync(specsDir)
27-
.filter((file) => file.endsWith(".md"));
28-
const specs = {};
29-
30-
specsFiles.forEach((file) => {
31-
const filePath = path.join(specsDir, file);
32-
const content = fs.readFileSync(filePath, "utf8");
33-
const htmlContent = marked(content);
34-
const fileName = path.basename(file, ".md");
35-
specs[fileName] = {
36-
title:
37-
fileName.charAt(0).toUpperCase() + fileName.slice(1).replace(/-/g, " "),
38-
content: htmlContent,
39-
};
40-
});
41-
42-
// Generate specs data for frontend
43-
const specsData = `const specsData = ${JSON.stringify(specs)};`;
44-
fs.writeFileSync("build/specs-data.js", specsData);
45-
46-
// Replace placeholder in template
47-
const finalHtml = template.replace("{{CONTENT}}", htmlContent);
48-
49-
// Write to build directory
50-
fs.writeFileSync("build/index.html", finalHtml);
51-
52-
console.log("✅ Website built successfully!");
4+
5+
(async () => {
6+
// Dynamically import ESM-only marked
7+
const { marked } = await import("marked");
8+
9+
// Read README.md
10+
const readmeContent = fs.readFileSync("README.md", "utf8");
11+
12+
// Read HTML template
13+
const template = fs.readFileSync("website/index.html", "utf8");
14+
15+
// Configure marked for GitHub-style rendering
16+
marked.setOptions({
17+
gfm: true,
18+
breaks: true,
19+
headerIds: true,
20+
mangle: false,
21+
});
22+
23+
// Convert markdown to HTML
24+
const htmlContent = marked(readmeContent);
25+
26+
// Read specs files
27+
const specsDir = "docs/specs";
28+
const specsFiles = fs
29+
.readdirSync(specsDir)
30+
.filter((file) => file.endsWith(".md"));
31+
const specs = {};
32+
33+
specsFiles.forEach((file) => {
34+
const filePath = path.join(specsDir, file);
35+
const content = fs.readFileSync(filePath, "utf8");
36+
const htmlSpec = marked(content);
37+
const fileName = path.basename(file, ".md");
38+
specs[fileName] = {
39+
title:
40+
fileName.charAt(0).toUpperCase() + fileName.slice(1).replace(/-/g, " "),
41+
content: htmlSpec,
42+
};
43+
});
44+
45+
// Generate specs data for frontend
46+
const specsData = `const specsData = ${JSON.stringify(specs)};`;
47+
fs.writeFileSync("build/specs-data.js", specsData);
48+
49+
// Replace placeholder in template
50+
const finalHtml = template.replace("{{CONTENT}}", htmlContent);
51+
52+
// Write to build directory
53+
fs.writeFileSync("build/index.html", finalHtml);
54+
55+
console.log("✅ Website built successfully!");
56+
})();

website/package-lock.json

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "wfh-indicator-website",
3+
"version": "1.0.0",
4+
"description": "Build dependencies for WFH Indicator website",
5+
"main": "build.js",
6+
"scripts": {
7+
"build": "node build.js"
8+
},
9+
"dependencies": {
10+
"marked": "^16.0.0"
11+
}
12+
}

0 commit comments

Comments
 (0)