chore: bump changelog sidebar

This commit is contained in:
hieu-jan 2024-03-15 09:11:16 +09:00
parent a91a95cdd7
commit b53541b2a4
17 changed files with 76 additions and 46 deletions

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 16 sidebar_position: 17
slug: /changelog/changelog-v0.2.0 slug: /changelog/changelog-v0.2.0
--- ---
# v0.2.0 # v0.2.0

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 15 sidebar_position: 16
slug: /changelog/changelog-v0.2.1 slug: /changelog/changelog-v0.2.1
--- ---
# v0.2.1 # v0.2.1

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 14 sidebar_position: 15
slug: /changelog/changelog-v0.2.2 slug: /changelog/changelog-v0.2.2
--- ---
# v0.2.2 # v0.2.2

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 13 sidebar_position: 14
slug: /changelog/changelog-v0.2.3 slug: /changelog/changelog-v0.2.3
--- ---
# v0.2.3 # v0.2.3

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 12 sidebar_position: 13
slug: /changelog/changelog-v0.3.0 slug: /changelog/changelog-v0.3.0
--- ---
# v0.3.0 # v0.3.0

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 11 sidebar_position: 12
slug: /changelog/changelog-v0.3.1 slug: /changelog/changelog-v0.3.1
--- ---
# v0.3.1 # v0.3.1

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 10 sidebar_position: 11
slug: /changelog/changelog-v0.3.2 slug: /changelog/changelog-v0.3.2
--- ---
# v0.3.2 # v0.3.2

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 9 sidebar_position: 10
slug: /changelog/changelog-v0.3.3 slug: /changelog/changelog-v0.3.3
--- ---
# v0.3.3 # v0.3.3

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 8 sidebar_position: 9
slug: /changelog/changelog-v0.4.0 slug: /changelog/changelog-v0.4.0
--- ---
# v0.4.0 # v0.4.0

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 7 sidebar_position: 8
slug: /changelog/changelog-v0.4.1 slug: /changelog/changelog-v0.4.1
--- ---
# v0.4.1 # v0.4.1

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 6 sidebar_position: 7
slug: /changelog/changelog-v0.4.2 slug: /changelog/changelog-v0.4.2
--- ---
# v0.4.2 # v0.4.2

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 5 sidebar_position: 6
slug: /changelog/changelog-v0.4.3 slug: /changelog/changelog-v0.4.3
--- ---
# v0.4.3 # v0.4.3

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 4 sidebar_position: 5
slug: /changelog/changelog-v0.4.4 slug: /changelog/changelog-v0.4.4
--- ---
# v0.4.4 # v0.4.4

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 3 sidebar_position: 4
slug: /changelog/changelog-v0.4.5 slug: /changelog/changelog-v0.4.5
--- ---
# v0.4.5 # v0.4.5

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 2 sidebar_position: 3
slug: /changelog/changelog-v0.4.6 slug: /changelog/changelog-v0.4.6
--- ---
# v0.4.6 # v0.4.6

View File

@ -1,5 +1,5 @@
--- ---
sidebar_position: 1 sidebar_position: 2
slug: /changelog/changelog-v0.4.7 slug: /changelog/changelog-v0.4.7
--- ---
# v0.4.7 # v0.4.7

View File

@ -68,6 +68,36 @@ async function fetchData(siteConfig, forceRefresh = false) {
return; return;
} }
// Check if there are new releases
const newReleases = releases.filter(release => {
const version = release.tag_name;
const existingChangelogPath = path.join(outputDirectory, `changelog-${version}.mdx`);
return !fs.existsSync(existingChangelogPath);
});
// If there are new releases, update existing changelog files' sidebar positions
if (newReleases.length > 0) {
console.log(`Updating sidebar positions for ${newReleases.length} new releases...`);
const existingChangelogFiles = fs.readdirSync(outputDirectory)
.filter(file => file.startsWith('changelog-'));
existingChangelogFiles.forEach((filename, index) => {
const version = filename.substring(10, filename.length - 4);
const existingChangelogPath = path.join(outputDirectory, filename);
const content = fs.readFileSync(existingChangelogPath, 'utf-8');
const sidebarPositionMatch = content.match(/sidebar_position: (\d+)/);
let sidebarPosition = index + 1;
if (sidebarPositionMatch) {
sidebarPosition = parseInt(sidebarPositionMatch[1]);
}
const updatedContent = content.replace(/sidebar_position: (\d+)/, `sidebar_position: ${sidebarPosition}`);
fs.writeFileSync(existingChangelogPath, updatedContent, 'utf-8');
console.log(`Sidebar position updated for changelog-${version}`);
});
}
// Process the GitHub releases data here // Process the GitHub releases data here
for (const release of releases) { for (const release of releases) {
const version = release.tag_name; const version = release.tag_name;