From 716a19bf4fe8d40ddc059699640d5585253e858f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 29 Aug 2024 23:17:22 +0200 Subject: [PATCH] microsite: conditional versioned docs config Signed-off-by: Patrik Oldsberg --- microsite/docusaurus.config.ts | 50 ++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/microsite/docusaurus.config.ts b/microsite/docusaurus.config.ts index 5eef7d0061..c6ceb21085 100644 --- a/microsite/docusaurus.config.ts +++ b/microsite/docusaurus.config.ts @@ -24,6 +24,8 @@ import { Config } from '@docusaurus/types'; const backstageTheme = themes.vsDark; backstageTheme.plain.backgroundColor = '#232323'; +const useVersionedDocs = require('fs').existsSync('versions.json'); + const config: Config = { title: 'Backstage Software Catalog and Developer Platform', tagline: 'An open source framework for building developer portals', @@ -57,22 +59,26 @@ const config: Config = { editUrl: 'https://github.com/backstage/backstage/edit/master/docs/', path: '../docs', sidebarPath: 'sidebars.json', - includeCurrentVersion: true, - lastVersion: 'stable', - versions: { - stable: { - label: 'Stable', - path: '/', - banner: 'none', - badge: false, - }, - current: { - label: 'Next', - path: '/next', - banner: 'unreleased', - badge: true, - }, - }, + ...(useVersionedDocs + ? { + includeCurrentVersion: true, + lastVersion: 'stable', + versions: { + stable: { + label: 'Stable', + path: '/', + banner: 'none', + badge: false, + }, + current: { + label: 'Next', + path: '/next', + banner: 'unreleased', + badge: true, + }, + }, + } + : undefined), }, blog: { path: 'blog', @@ -275,10 +281,14 @@ const config: Config = { label: 'Community', position: 'left', }, - { - type: 'docsVersionDropdown', - position: 'right', - }, + ...(useVersionedDocs + ? [ + { + type: 'docsVersionDropdown', + position: 'right' as const, + }, + ] + : []), ], }, image: 'img/sharing-opengraph.png',