Skip to content

Commit

Permalink
also build latest
Browse files Browse the repository at this point in the history
  • Loading branch information
eri24816 committed May 10, 2024
1 parent fdda03d commit 5f5a5ce
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion scripts/hugo_build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,22 @@ versions.forEach((version) => {
const hugoToml = `baseURL = "${baseURLRoot}/${version}"\ncontentDir = "content/${version}"\npublishDir = "public/${version}"`;
require('fs').writeFileSync('hugo.toml', hugoToml);
execSync(`hugo`);
});
});

// build the latest version to latest
// sort the versions 'v{a}.{b}.{c}' and get the latest
const data = versions.map((v) => {
const [a, b, c] = v.split('.').map((x) => parseInt(x));
return { a, b, c, v };
}).sort((a, b) => {
if (a.a !== b.a) return a.a - b.a;
if (a.b !== b.b) return a.b - b.b;
return a.c - b.c;
}
);
const latestVersion = data[data.length - 1].v;
console.log(`Building version latest (${latestVersion})`);
const hugoToml = `baseURL = "${baseURLRoot}/latest"\ncontentDir = "content/${latestVersion}"\npublishDir = "public/latest"`;
require('fs').writeFileSync('hugo.toml', hugoToml);
execSync(`hugo`);

0 comments on commit 5f5a5ce

Please sign in to comment.