Skip to content

Commit

Permalink
hint for #2143
Browse files Browse the repository at this point in the history
  • Loading branch information
adrai committed Apr 13, 2023
1 parent 49b8355 commit aa0f30a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/ssg/components/LanguageSwitchLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const LanguageSwitchLink = ({ locale, ...rest }) => {
if (locale) {
href = rest.href ? `/${locale}${rest.href}` : pName
}
if (href.indexOf(`/${locale}`) < 0) {
href = `/${locale}${href}`
}

return (
<Link href={href}>
Expand Down
2 changes: 1 addition & 1 deletion examples/ssg/lib/getStatic.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const getStaticPaths = () => ({
})

export const getI18nProps = async (ctx, ns = ['common']) => {
const locale = ctx?.params?.locale
const locale = ctx?.params?.locale || i18nextConfig.i18n.defaultLocale
let props = {
...(await serverSideTranslations(locale, ns)),
}
Expand Down
6 changes: 6 additions & 0 deletions examples/ssg/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
// to detect language and automatically redirect to the approprate/[locale] page
import { Redirect } from '../lib/redirect'
export default Redirect

// to keep this root page with the defaultLocale
// import Homepage, { getStaticProps } from './[locale]/index'
// export default Homepage
// export { getStaticProps }
6 changes: 6 additions & 0 deletions examples/ssg/pages/second-page.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
// to detect language and automatically redirect to the approprate/[locale] page
import { Redirect } from '../lib/redirect'
export default Redirect

// to keep this root page with the defaultLocale
// import SecondPage, { getStaticProps } from './[locale]/second-page'
// export default SecondPage
// export { getStaticProps }

0 comments on commit aa0f30a

Please sign in to comment.