File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const Layout = (props: {
22
22
const { currentLanguage } =
23
23
language && language . currentLanguage ? language : { currentLanguage : "en" }
24
24
const lightMode = state ?. setting ?. lightMode
25
+ const currentVersion = state ?. setting ?. version
25
26
const [ show , setShow ] = React . useState ( false )
26
27
const scrollHandler = ( ) => {
27
28
if ( window . scrollY > 75 ) {
@@ -30,7 +31,11 @@ const Layout = (props: {
30
31
setShow ( false )
31
32
}
32
33
}
33
- const editLink = getEditLink ( currentLanguage , props . location ?. pathname )
34
+ const editLink = getEditLink (
35
+ currentVersion ,
36
+ currentLanguage ,
37
+ props . location ?. pathname
38
+ )
34
39
35
40
React . useEffect ( ( ) => {
36
41
window . addEventListener ( "scroll" , scrollHandler )
Original file line number Diff line number Diff line change 1
1
const preFix =
2
- "https://github.com/react-hook-form/documentation/edit/master /src/data/"
2
+ "https://github.com/react-hook-form/documentation/edit/v6-v5 /src/data/"
3
3
4
4
export const getEditLink = (
5
+ currentVersion : number ,
5
6
currentLanguage : string ,
6
7
pathname : string
7
8
) : string => {
8
9
if ( ! pathname ) return ""
9
10
11
+ let versionTag = ""
12
+ if ( currentVersion === 6 ) {
13
+ versionTag = "V6/"
14
+ } else if ( currentVersion === 5 ) {
15
+ versionTag = "V5/"
16
+ }
17
+
10
18
if ( pathname === "/" || pathname === "" ) {
11
19
return preFix + "home.tsx"
12
20
} else if ( pathname . includes ( "get-started" ) ) {
13
21
return `${ preFix } ${ currentLanguage } /getStarted.tsx`
14
22
} else if ( pathname . includes ( "api" ) ) {
15
- return `${ preFix } ${ currentLanguage } /api.tsx`
23
+ return `${ preFix } ${ versionTag } ${ currentLanguage } /api.tsx`
16
24
} else if ( pathname . includes ( "ts" ) ) {
17
25
return `${ preFix } ts.tsx`
18
26
} else if ( pathname . includes ( "advanced-usage" ) ) {
19
- return `${ preFix } ${ currentLanguage } /advanced.tsx`
27
+ const tag = currentVersion < 7 && currentLanguage === "en" ? "V6/" : ""
28
+ return `${ preFix } ${ tag } ${ currentLanguage } /advanced.tsx`
20
29
} else if ( pathname . includes ( "faqs" ) ) {
21
30
return `${ preFix } ${ currentLanguage } /faq.tsx`
22
31
} else if ( pathname . includes ( "dev-tools" ) ) {
You can’t perform that action at this time.
0 commit comments