blob: 05b92f369bbf458b510ecf38b4c72d72e40f6bd9 [file]
import { VERSION_CURRENT } from "@site/src/constants";
import { getStorage } from "@site/src/util/localStorage";
export const historyPushLinkAt = (
path: string
) => {
const basePath = ''
const { pathname } = window.location
const lang = pathname.includes('/zh-CN') ? '/zh-CN' : ''
const [navpath, route] = path?.replace('\/', ',')?.split(',')
const current = getStorage('VERSION') || VERSION_CURRENT
const versiton = current === VERSION_CURRENT || navpath !== 'docs' ? '' : `/${current}`
let navLang = `/${navpath}${versiton}`
if (['docs', 'community'].includes(navpath) && pathname.includes('/zh-CN')) {
navLang = `${navLang}/zh`
}
return `${basePath}${lang}${navLang + '/' + route}`
};