Skip to content

Commit b8ea65b

Browse files
committed
Generate href ahead of time
1 parent 5bafabe commit b8ea65b

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ void_guides_outputs = \
7171

7272
dist/void-guides/db.json: compile-db.js $(void_guides_sources)
7373
mkdir -p dist/void-guides
74-
node compile-db.js $@ $(sort $(void_guides_sources))
74+
node compile-db.js \
75+
void-guides void-guides/ \
76+
$(sort $(void_guides_sources))
7577

7678
dist/void-guides/%.html: \
7779
src/templates/docs.html src/main.html src/submodules/void-guides/%.md \

compile-db.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ function readFile(path) {
2121

2222
// Parse inputs.
2323
const db = [];
24-
const output = process.argv[2];
25-
const inputs = process.argv.slice(3);
24+
25+
const repo = process.argv[2];
26+
const prefix = process.argv[3];
27+
28+
const output = `dist/${repo}/db.json`;
29+
const inputs = process.argv.slice(4);
2630

2731
for (const input of inputs) {
2832
// Initialize entry and push it to database.
@@ -32,6 +36,11 @@ for (const input of inputs) {
3236

3337
db.push(entry);
3438

39+
// Generate link.
40+
let href = input.substring(15 + prefix.length, input.length - 3);
41+
42+
entry.href = `/${repo}/${href}`;
43+
3544
// Read file contents.
3645
entry.content = readFile(input);
3746

0 commit comments

Comments
 (0)