Skip to content

Commit b7868b5

Browse files
authored
fix: version name (#1005)
1 parent c1d4299 commit b7868b5

File tree

1 file changed

+13
-1
lines changed
  • packages/plugin-docusaurus-v3/src/theme/SearchBar

1 file changed

+13
-1
lines changed

packages/plugin-docusaurus-v3/src/theme/SearchBar/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,26 @@ export function OramaSearchNoDocs() {
7272
)
7373
}
7474

75+
function getVersionName(version: string | { name: string } | null): string | undefined {
76+
if (!version) {
77+
return undefined
78+
}
79+
80+
if (typeof version === 'string') {
81+
return version
82+
}
83+
84+
return version.name
85+
}
86+
7587
export function OramaSearchWithDocs({ pluginId }: { pluginId: string }) {
7688
const colorMode = getColorMode()
7789
const { searchBoxConfig, searchBtnConfig } = useOrama()
7890
const collectionManager = searchBoxConfig.basic?.collectionManager
7991
const versions = useVersions(pluginId)
8092
const activeVersion = useActiveVersion(pluginId)
8193
const preferredVersion = getPreferredVersion(searchBoxConfig.basic.clientInstance)
82-
const currentVersion = activeVersion || preferredVersion || versions[0]
94+
const currentVersion = getVersionName(activeVersion) || getVersionName(preferredVersion) || getVersionName(versions[0]);
8395

8496
const searchParams = {
8597
...(currentVersion && {

0 commit comments

Comments
 (0)