rsnext/test/integration/i18n-support-same-page-hash-change/pages/posts/[...slug].js
Tim Neutkens f260328900
BREAKING CHANGE: Enable newNextLinkBehavior (#41459)
- Enable newNextLinkBehavior. See #36436 
- Run next/link codemod on test suite

Note that from when this lands on apps trying canary will need to run
the new-link codemod in order to upgrade.
Ideally we have to detect `<a>` while rendering the new link and warn
for it.

Co-authored-by: Steven <steven@ceriously.com>
2022-10-17 21:20:28 -04:00

44 lines
829 B
JavaScript

import Link from 'next/link'
import { useRouter } from 'next/router'
export default function Page(props) {
const router = useRouter()
return (
<>
<p id="props-locale">{props.locale}</p>
<p id="router-locale">{router.locale}</p>
<Link
href={{ pathname: router.pathname, query: router.query, hash: '#hash' }}
locale={router.locale === 'fr' ? 'en' : 'fr'}
id="change-locale"
>
Change Locale
</Link>
</>
)
}
export const getStaticProps = async ({ locale }) => {
return {
props: {
locale,
},
}
}
export const getStaticPaths = () => {
return {
paths: [
{
params: { slug: ['a'] },
locale: 'en',
},
{
params: { slug: ['a'] },
locale: 'fr',
},
],
fallback: false,
}
}