File tree Expand file tree Collapse file tree 4 files changed +36
-2
lines changed
Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -41,7 +41,15 @@ const config: Config = {
4141 // may want to replace "en" with "zh-Hans".
4242 i18n : {
4343 defaultLocale : 'ja' ,
44- locales : [ 'ja' ] ,
44+ locales : [ 'ja' , 'en' ] ,
45+ localeConfigs : {
46+ en : {
47+ label : 'English' ,
48+ } ,
49+ ja : {
50+ label : '日本語' ,
51+ } ,
52+ } ,
4553 } ,
4654
4755 presets : [
@@ -136,6 +144,10 @@ const config: Config = {
136144 label : 'JDL Studio' ,
137145 position : 'right' ,
138146 } ,
147+ {
148+ type : 'localeDropdown' ,
149+ position : 'right' ,
150+ } ,
139151 ] ,
140152 } ,
141153 prism : {
@@ -178,6 +190,13 @@ const config: Config = {
178190 } ) ,
179191 } ,
180192 ] ,
193+
194+ scripts : [
195+ {
196+ src : '/redirect.js' ,
197+ async : true ,
198+ } ,
199+ ] ,
181200} ;
182201
183202export default config ;
Original file line number Diff line number Diff line change @@ -201,7 +201,7 @@ const redirectsPlugin = [
201201 {
202202 from : '/tips.html' ,
203203 to : '/tips/' ,
204- } ,
204+ } ,
205205 ] ,
206206 } ,
207207] ;
Original file line number Diff line number Diff line change 1+ // https://docusaurus.io/docs/api/docusaurus-config#i18n
2+ // workaround for 'baseUrl—customization of base URL is a work-in-progress.'
3+ export default function onRouteUpdate ( { location } ) {
4+ const prefix = '/jp/en/' ;
5+ if ( location . pathname . startsWith ( prefix ) ) {
6+ const newPath = location . pathname . replace ( prefix , '/' ) ;
7+ window . location . replace ( newPath ) ;
8+ }
9+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import NavbarMobileSidebar from '@theme/Navbar/MobileSidebar';
1010import type { Props } from '@theme/Navbar/Layout' ;
1111
1212import styles from './styles.module.scss' ;
13+ import onRouteUpdate from '../../../redirect' ;
1314
1415function NavbarBackdrop ( props : ComponentProps < 'div' > ) {
1516 return (
@@ -22,6 +23,11 @@ function NavbarBackdrop(props: ComponentProps<'div'>) {
2223}
2324
2425export default function NavbarLayout ( { children } : Props ) : JSX . Element {
26+
27+ React . useEffect ( ( ) => {
28+ onRouteUpdate ( { location : window . location } ) ;
29+ } , [ ] ) ;
30+
2531 const {
2632 navbar : { hideOnScroll, style } ,
2733 } = useThemeConfig ( ) ;
You can’t perform that action at this time.
0 commit comments