chore: move some things to typescript
Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -22,6 +22,7 @@ import { themes } from 'prism-react-renderer';
|
||||
import type * as Preset from '@docusaurus/preset-classic';
|
||||
import { Config } from '@docusaurus/types';
|
||||
import RedirectPlugin from '@docusaurus/plugin-client-redirects';
|
||||
import { releases } from './releases';
|
||||
|
||||
const backstageTheme = themes.vsDark;
|
||||
backstageTheme.plain.backgroundColor = '#232323';
|
||||
@@ -85,7 +86,7 @@ const config: Config = {
|
||||
docs: {
|
||||
editUrl: 'https://github.com/backstage/backstage/edit/master/docs/',
|
||||
path: '../docs',
|
||||
sidebarPath: 'sidebars.mjs',
|
||||
sidebarPath: 'sidebars.ts',
|
||||
...(useVersionedDocs
|
||||
? {
|
||||
includeCurrentVersion: true,
|
||||
@@ -295,7 +296,7 @@ const config: Config = {
|
||||
position: 'left',
|
||||
},
|
||||
{
|
||||
to: 'docs/releases/v1.30.0',
|
||||
to: `docs/releases/${releases[0]}`,
|
||||
label: 'Releases',
|
||||
position: 'left',
|
||||
},
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const docsDir = path.resolve(
|
||||
path.dirname(new URL(import.meta.url).pathname),
|
||||
'../docs',
|
||||
);
|
||||
|
||||
export const releases = fs
|
||||
.readdirSync(path.resolve(docsDir, 'releases'))
|
||||
.filter(doc => doc.match(/^v\d+\.\d+\.\d+\.md$/))
|
||||
.map(doc => doc.replace(/\.md$/, ''))
|
||||
.sort((a, b) => {
|
||||
// Semver sort
|
||||
const aVal = a
|
||||
.slice(1)
|
||||
.split('.')
|
||||
.reduce((acc, val) => acc * 1000 + parseInt(val), 0);
|
||||
const bVal = b
|
||||
.slice(1)
|
||||
.split('.')
|
||||
.reduce((acc, val) => acc * 1000 + parseInt(val), 0);
|
||||
return bVal - aVal;
|
||||
});
|
||||
@@ -1,21 +1,4 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const docsDir = path.resolve(
|
||||
path.dirname(new URL(import.meta.url).pathname),
|
||||
'../docs',
|
||||
);
|
||||
|
||||
const allReleaseDocs = fs.readdirSync(path.resolve(docsDir, 'releases'));
|
||||
const mainRleases = allReleaseDocs
|
||||
.filter(doc => doc.match(/^v\d+\.\d+\.\d+\.md$/))
|
||||
.map(doc => doc.replace(/\.md$/, ''))
|
||||
.sort((a, b) => { // Semver sort
|
||||
const aVal = a.slice(1).split('.').reduce((acc, val) => acc * 1000 + parseInt(val), 0);
|
||||
const bVal = b.slice(1).split('.').reduce((acc, val) => acc * 1000 + parseInt(val), 0);
|
||||
return bVal - aVal;
|
||||
})
|
||||
.map(release => `releases/${release}`);
|
||||
import { releases } from './releases';
|
||||
|
||||
export default {
|
||||
docs: {
|
||||
@@ -543,6 +526,6 @@ export default {
|
||||
References: ['references/glossary'],
|
||||
},
|
||||
releases: {
|
||||
'Release Notes': mainRleases
|
||||
'Release Notes': releases.map(release => `releases/${release}`),
|
||||
},
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
"extends": "@docusaurus/tsconfig",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"allowJs": true,
|
||||
"types": [
|
||||
"node",
|
||||
"@docusaurus/module-type-aliases",
|
||||
|
||||
Reference in New Issue
Block a user