-
Notifications
You must be signed in to change notification settings - Fork 29
/
generate-release-index.js
66 lines (48 loc) · 1.85 KB
/
generate-release-index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const fs = require("fs");
const path = require("path");
const docsDir = path.join(__dirname, "./docs/release-stable");
const releaseNote = path.join(__dirname, "./docs/en/release-notes");
const releaseNoteCN = path.join(__dirname, "./docs/cn/release-notes");
const outputPath = path.join(releaseNote, "databend.md");
const outputPathCN = path.join(releaseNoteCN, "databend.md");
function formatTime(dateStr) {
const options = { year: "numeric", month: "short", day: "numeric" };
const dateObj = new Date(dateStr);
return dateObj.toLocaleDateString("en-US", options);
}
const mdFiles = fs
.readdirSync(docsDir)
.filter((file) => file.endsWith(".md") && file !== "index.md")
?.reverse();
let imports = "";
let content = "";
mdFiles?.forEach((file, index) => {
const [time, version] = file.split("_");
const V = version.slice(0, -3);
const varName = `MD${index + 1}`;
imports += `import ${varName} from '@site/docs/release-stable/${file}';\n`;
content += `\n\n<StepContent outLink="https://github.com/datafuselabs/databend/releases/tag/${V}" number="${
index === 0 ? "-1" : ""
}">
## ${formatTime(time)} (${V})
<${varName} />
</StepContent>`;
// posts.push({title: V, link: `https://github.com/datafuselabs/databend/releases/tag/${V}`, description: 'Databend release notes', pubDate: time})
});
const outputData = `---
sidebar_label: Databend Releases
title: Databend Releases
sidebar_position: 1
slug: /
---
import StepsWrap from '@site/src/components/StepsWrap';
import StepContent from '@site/src/components/Steps/step-content';
This page provides information about recent features, enhancements, and bug fixes for <a href="https://github.com/datafuselabs/databend">Databend</a>.
${imports}
<StepsWrap>
${content}
</StepsWrap>
`;
fs.writeFileSync(outputPath, outputData);
fs.writeFileSync(outputPathCN, outputData);
console.log("generated");