update useDocLink

pull/20801/head
Bowen Liang 12 months ago
parent 52450a08fb
commit 0e8c76599c

@ -43,8 +43,9 @@ export const useDocLink = (baseUrl?: string): ((path?: string, pathMap?: { [inde
return (path?: string, pathMap?: { [index: string]: string }): string => { return (path?: string, pathMap?: { [index: string]: string }): string => {
const docLanguage = getDocLanguage(locale) const docLanguage = getDocLanguage(locale)
const pathUrl = path || '' const pathUrl = path || ''
const targetPath = (pathMap) ? pathMap[locale] || pathUrl : pathUrl let targetPath = (pathMap) ? pathMap[locale] || pathUrl : pathUrl
return (targetPath.startsWith('/')) ? `${baseDocUrl}/${docLanguage}${targetPath}` : `${baseDocUrl}/${docLanguage}/${targetPath}` targetPath = (targetPath.startsWith('/')) ? targetPath.slice(0, -1) : targetPath
return `${baseDocUrl}/${docLanguage}/${targetPath}`
} }
} }
export default I18NContext export default I18NContext

Loading…
Cancel
Save