1- import React from 'react' ;
1+ import React , { useEffect , useState } from 'react' ;
22import Translate , { translate } from '@docusaurus/Translate' ;
33import { PageMetadata } from '@docusaurus/theme-common' ;
44import Layout from '@theme/Layout' ;
55import ExternalLink from '../components/external-link/external-link' ;
66import { ExternalLinkArrowIcon } from '@site/src/components/Icons/external-link-arrow-icon' ;
7+
8+ // Legacy /docs/dev/* URLs may still be linked from external sites. Pages with a
9+ // 1:1 match under /docs-next/dev/ are redirected at build time; pages without
10+ // one land here. Detect the legacy prefix and show guidance to the new Dev docs
11+ // entry instead of the generic 404.
12+ const LEGACY_DEV_GUIDANCE = {
13+ en : {
14+ title : 'This Dev doc has moved' ,
15+ description :
16+ 'The legacy /docs/dev/ tree has been retired. The page you requested is no longer available at this URL.' ,
17+ linkLabel : 'Go to new Dev docs' ,
18+ linkTo : '/docs-next/dev/getting-started/what-is-apache-doris' ,
19+ } ,
20+ 'zh-CN' : {
21+ title : 'Dev 文档已迁移' ,
22+ description :
23+ '/docs/dev/ 下的旧文档已下线,此 URL 对应的页面不再可用。请前往新版 Dev 文档继续浏览。' ,
24+ linkLabel : '前往新版 Dev 文档' ,
25+ linkTo : '/zh-CN/docs-next/dev/getting-started/what-is-apache-doris' ,
26+ } ,
27+ } ;
28+
29+ function detectLegacyDevLocale ( pathname ) {
30+ if ( ! pathname ) return null ;
31+ if ( pathname === '/zh-CN/docs/dev' || pathname . startsWith ( '/zh-CN/docs/dev/' ) ) {
32+ return 'zh-CN' ;
33+ }
34+ if ( pathname === '/docs/dev' || pathname . startsWith ( '/docs/dev/' ) ) {
35+ return 'en' ;
36+ }
37+ return null ;
38+ }
39+
40+ function LegacyDevGuidance ( { locale } ) {
41+ const copy = LEGACY_DEV_GUIDANCE [ locale ] ;
42+ return (
43+ < main className = "container margin-vert--xl" >
44+ < div className = "row" >
45+ < div className = "col" >
46+ < div className = "flex justify-center mb-10" >
47+ < img
48+ style = { { width : 120 } }
49+ src = { require ( '@site/static/images/empty-data.png' ) . default }
50+ alt = ""
51+ />
52+ </ div >
53+ < h1 className = "text-[1.75rem] text-[#1D1D1D] leading-[1.6] text-center" >
54+ { copy . title }
55+ </ h1 >
56+ < p className = "text-center mt-2 text-sm text-[#8592A6]" >
57+ { copy . description }
58+ </ p >
59+ < div className = "flex justify-center gap-x-6 lg:gap-x-10 mt-10" >
60+ < div className = "w-[12.5rem]" >
61+ < ExternalLink
62+ to = { copy . linkTo }
63+ label = { copy . linkLabel }
64+ className = "text-sm h-[2.625rem] bg-primary text-white rounded-md hover:text-white cursor-pointer"
65+ linkIcon = { < ExternalLinkArrowIcon /> }
66+ />
67+ </ div >
68+ </ div >
69+ </ div >
70+ </ div >
71+ </ main >
72+ ) ;
73+ }
74+
775export default function NotFound ( ) {
76+ const [ legacyDevLocale , setLegacyDevLocale ] = useState ( null ) ;
77+
78+ useEffect ( ( ) => {
79+ if ( typeof window !== 'undefined' ) {
80+ setLegacyDevLocale ( detectLegacyDevLocale ( window . location . pathname ) ) ;
81+ }
82+ } , [ ] ) ;
83+
884 return (
985 < >
1086 < PageMetadata
@@ -14,48 +90,52 @@ export default function NotFound() {
1490 } ) }
1591 />
1692 < Layout >
17- < main className = "container margin-vert--xl" >
18- < div className = "row" >
19- < div className = "col" >
20- < div className = "flex justify-center mb-10" >
21- < img
22- style = { { width : 120 } }
23- src = { require ( '@site/static/images/empty-data.png' ) . default }
24- alt = ""
25- />
26- </ div >
27- < h1 className = "text-[1.75rem] text-[#1D1D1D] leading-[1.6] text-center" >
28- < Translate id = "theme.NotFound.title" description = "The title of the 404 page" >
29- Page Not Found
30- </ Translate >
31- </ h1 >
32- < p className = "text-center mt-2 text-sm text-[#8592A6]" >
33- < Translate id = "theme.NotFound.p1" description = "The first paragraph of the 404 page" >
34- Oops! The page you are looking for can't be found. In any case, try to look for a
35- different page or report this issue.
36- </ Translate >
37- </ p >
38- < div className = "flex justify-center gap-x-6 lg:gap-x-10 mt-10" >
39- < div className = "w-[9.75rem]" >
40- < ExternalLink
41- to = "/"
42- label = "Go to home"
43- className = "text-sm h-[2.625rem] bg-primary text-white rounded-md hover:text-white cursor-pointer"
44- linkIcon = { < ExternalLinkArrowIcon /> }
93+ { legacyDevLocale ? (
94+ < LegacyDevGuidance locale = { legacyDevLocale } />
95+ ) : (
96+ < main className = "container margin-vert--xl" >
97+ < div className = "row" >
98+ < div className = "col" >
99+ < div className = "flex justify-center mb-10" >
100+ < img
101+ style = { { width : 120 } }
102+ src = { require ( '@site/static/images/empty-data.png' ) . default }
103+ alt = ""
45104 />
46105 </ div >
47- < div className = "w-[9.75rem]" >
48- < ExternalLink
49- label = "Report this issue"
50- linkIcon = { < ExternalLinkArrowIcon /> }
51- to = "https://github.com/apache/doris-website/issues"
52- className = "text-sm border border-primary h-[2.625rem] rounded-md text-primary cursor-pointer"
53- />
106+ < h1 className = "text-[1.75rem] text-[#1D1D1D] leading-[1.6] text-center" >
107+ < Translate id = "theme.NotFound.title" description = "The title of the 404 page" >
108+ Page Not Found
109+ </ Translate >
110+ </ h1 >
111+ < p className = "text-center mt-2 text-sm text-[#8592A6]" >
112+ < Translate id = "theme.NotFound.p1" description = "The first paragraph of the 404 page" >
113+ Oops! The page you are looking for can't be found. In any case, try to look for a
114+ different page or report this issue.
115+ </ Translate >
116+ </ p >
117+ < div className = "flex justify-center gap-x-6 lg:gap-x-10 mt-10" >
118+ < div className = "w-[9.75rem]" >
119+ < ExternalLink
120+ to = "/"
121+ label = "Go to home"
122+ className = "text-sm h-[2.625rem] bg-primary text-white rounded-md hover:text-white cursor-pointer"
123+ linkIcon = { < ExternalLinkArrowIcon /> }
124+ />
125+ </ div >
126+ < div className = "w-[9.75rem]" >
127+ < ExternalLink
128+ label = "Report this issue"
129+ linkIcon = { < ExternalLinkArrowIcon /> }
130+ to = "https://github.com/apache/doris-website/issues"
131+ className = "text-sm border border-primary h-[2.625rem] rounded-md text-primary cursor-pointer"
132+ />
133+ </ div >
54134 </ div >
55135 </ div >
56136 </ div >
57- </ div >
58- </ main >
137+ </ main >
138+ ) }
59139 </ Layout >
60140 </ >
61141 ) ;
0 commit comments