Skip to content

Commit

Permalink
fix: doc versions (kubernetes#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
g1eny0ung authored Sep 8, 2020
1 parent bc08a36 commit a89a9d0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/PickVersion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import { usePluginData } from '@docusaurus/useGlobalData'

export const usePickVersion = () => {
const locationHref = window.location.href
const contentDocsData = usePluginData('docusaurus-plugin-content-docs')
const latestVersion = contentDocsData.latestVersionName
let activeVersion = contentDocsData.versions.filter((d) => locationHref.includes(d.path)).map((d) => d.name)[0]
const { versions } = usePluginData('docusaurus-plugin-content-docs')

if (activeVersion === 'next') {
const latestStableVersion = versions.filter((d) => d.isLast)[0].name
let activeVersion = versions.filter((d) => locationHref.includes(d.name)).map((d) => d.name)[0]

if (locationHref.includes('/docs/next')) {
activeVersion = 'latest'
}

return activeVersion || latestVersion
return activeVersion || latestStableVersion
}

const PickVersion = ({ children, className }) => {
Expand Down

0 comments on commit a89a9d0

Please sign in to comment.