Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs-releases/sidebars.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';
import {readdirSync} from 'node:fs';
import {fileURLToPath} from 'node:url';
import semver from 'semver';

// Order release docs by descending semver precedence (newest on top). Built
// explicitly here rather than via sidebar_position frontmatter so arbitrary
// prereleases sort correctly and new release files are picked up automatically.
const dir = fileURLToPath(new URL('.', import.meta.url));
const releaseDocs = readdirSync(dir)
.filter((f) => f.endsWith('.md') && f !== 'index.md')
.map((f) => f.replace(/\.md$/, ''))
.filter((id) => semver.valid(id.replace(/^v/, '')))
.sort((a, b) => semver.rcompare(a, b));

const sidebars: SidebarsConfig = {
releasesSidebar: [{type: 'autogenerated', dirName: '.'}],
releasesSidebar: ['index', ...releaseDocs],
};

export default sidebars;
10 changes: 1 addition & 9 deletions scripts/sync-release-note.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { join } from "node:path";
import { argv, env, exit } from "node:process";


const flags = {};
for (let i = 2; i < argv.length; i++) {
const a = argv[i];
Expand All @@ -20,14 +21,6 @@ function slugify(s) {
return String(s).replace(/[^A-Za-z0-9.+-]/g, "-");
}

// this puts the newest releases first
function sidebarPos(t) {
const m = String(t).match(/^v?(\d+)\.(\d+)\.(\d+)/);
if (!m) return 0;
const [, maj, min, pat] = m.map(Number);
return -(maj * 1_000_000 + min * 1_000 + pat);
}

function escapeFrontmatter(s) {
return String(s).replace(/"/g, '\\"');
}
Expand Down Expand Up @@ -102,7 +95,6 @@ function buildMarkdown(r) {
"---",
`title: "${escapeFrontmatter(r.title)}"`,
`sidebar_label: "${escapeFrontmatter(r.tag)}"`,
`sidebar_position: ${sidebarPos(r.tag)}`,
`slug: /${slugify(r.tag)}`,
r.publishedAt ? `date: ${r.publishedAt}` : null,
"---",
Expand Down
Loading