From e28d6d42204151e8ae9dc5be16e84f3226b7da4b Mon Sep 17 00:00:00 2001 From: Bowen Liang Date: Sat, 7 Jun 2025 22:47:08 +0800 Subject: [PATCH] add getDocLink method --- web/context/i18n.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/context/i18n.ts b/web/context/i18n.ts index 463e01d1c5..04d49d2808 100644 --- a/web/context/i18n.ts +++ b/web/context/i18n.ts @@ -3,6 +3,7 @@ import { useContext, } from 'use-context-selector' import type { Locale } from '@/i18n' +import { getLocaleOnClient } from '@/i18n' import { getDocLanguage, getLanguage, getPricingPageLanguage } from '@/i18n/language' import { noop } from 'lodash-es' @@ -35,4 +36,10 @@ export const useGetPricingPageLanguage = () => { return getPricingPageLanguage(locale) } +const baseDocUrl = 'https://docs.dify.ai' +export const getDocLink = (path: string) => { + const docLanguage = getLocaleOnClient() === 'zh-Hans' ? '/zh-hans' : '/' + return `${baseDocUrl}${docLanguage}/${path}` +} + export default I18NContext