Skip to content

Commit

Permalink
Fix syntax for dynamic docs versioning (woodpecker-ci#4708)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys authored Jan 12, 2025
1 parent e13fee1 commit 3e295f7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 12 deletions.
7 changes: 2 additions & 5 deletions docs/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { readFile } from 'node:fs/promises';
const config = require('../.prettierrc.json');

// eslint-disable-next-line antfu/no-top-level-await
const config = JSON.parse(await readFile(new URL('../.prettierrc.json', import.meta.url)));

export default {
module.exports = {
...config,
plugins: ['@ianvs/prettier-plugin-sort-imports'],
importOrder: [
Expand Down
14 changes: 8 additions & 6 deletions docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import * as path from 'path';
import type { VersionBanner, VersionOptions } from '@docusaurus/plugin-content-docs';
import type * as Preset from '@docusaurus/preset-classic';
import type { Config } from '@docusaurus/types';
import { themes } from 'prism-react-renderer';
import * as versions from './versions.json';

const docsVersions = {
import versions from './versions.json';

const docsVersions: { [version: string]: VersionOptions } = {
current: {
label: 'Next 🚧',
banner: 'unreleased',
banner: 'unreleased' as VersionBanner,
},
};

const includeVersions = ['current', versions.default[0]];
const includeVersions = ['current', versions[0]];

versions.default.forEach((v, index) => {
versions.forEach((v, index) => {
const version = {
label: `${v}.x${index === 0 ? '' : ' 💀'}`,
};
Expand Down Expand Up @@ -257,7 +259,7 @@ const config = {
sidebarPath: require.resolve('./sidebars.js'),
editUrl: '/~https://github.com/woodpecker-ci/woodpecker/edit/main/docs/',
includeCurrentVersion: true,
lastVersion: versions.default[0],
lastVersion: versions[0],
onlyIncludeVersions: includeVersions,
versions: docsVersions,
},
Expand Down
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@docusaurus/module-type-aliases": "^3.7.0",
"@docusaurus/tsconfig": "3.7.0",
"@docusaurus/types": "^3.7.0",
"@ianvs/prettier-plugin-sort-imports": "^4.4.0",
"@types/node": "^22.10.5",
"@types/react": "^19.0.0",
"@types/react-helmet": "^6.1.11",
Expand Down
32 changes: 31 additions & 1 deletion docs/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3e295f7

Please sign in to comment.