try url object with next/link to fix #822
This commit is contained in:
parent
2bbcbfbb26
commit
04991b4ddf
@ -217,8 +217,8 @@ function LurkerCorner ({ path }) {
|
|||||||
|
|
||||||
const PREPEND_SUBS = ['home']
|
const PREPEND_SUBS = ['home']
|
||||||
const APPEND_SUBS = [{ label: '--------', items: ['create'] }]
|
const APPEND_SUBS = [{ label: '--------', items: ['create'] }]
|
||||||
function NavItems ({ className, sub, prefix }) {
|
function NavItems ({ className, sub: subName, prefix }) {
|
||||||
sub ||= 'home'
|
const sub = subName || 'home'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -240,7 +240,12 @@ function NavItems ({ className, sub, prefix }) {
|
|||||||
</Nav.Item>
|
</Nav.Item>
|
||||||
{sub !== 'jobs' &&
|
{sub !== 'jobs' &&
|
||||||
<Nav.Item className={className}>
|
<Nav.Item className={className}>
|
||||||
<Link href={prefix + '/top/posts/day'} passHref legacyBehavior>
|
<Link
|
||||||
|
href={{
|
||||||
|
pathname: '/~/top/[type]/[when]',
|
||||||
|
query: { type: 'posts', when: 'day', sub: subName }
|
||||||
|
}} as={prefix + '/top/posts/day'} passHref legacyBehavior
|
||||||
|
>
|
||||||
<Nav.Link eventKey='top' className={styles.navLink}>top</Nav.Link>
|
<Nav.Link eventKey='top' className={styles.navLink}>top</Nav.Link>
|
||||||
</Link>
|
</Link>
|
||||||
</Nav.Item>}
|
</Nav.Item>}
|
||||||
|
@ -58,6 +58,12 @@ export default function MyApp ({ Component, pageProps: { ...props } }) {
|
|||||||
// this nodata var will get passed to the server on back/foward and
|
// this nodata var will get passed to the server on back/foward and
|
||||||
// 1. prevent data from reloading and 2. perserve scroll
|
// 1. prevent data from reloading and 2. perserve scroll
|
||||||
// (2) is not possible while intercepting nav with beforePopState
|
// (2) is not possible while intercepting nav with beforePopState
|
||||||
|
|
||||||
|
console.log({
|
||||||
|
pathname: router.pathname,
|
||||||
|
query: { ...router.query, nodata: true }
|
||||||
|
}, router.asPath, { ...router.options, shallow: true })
|
||||||
|
|
||||||
router.replace({
|
router.replace({
|
||||||
pathname: router.pathname,
|
pathname: router.pathname,
|
||||||
query: { ...router.query, nodata: true }
|
query: { ...router.query, nodata: true }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user