wait for hydration before url manipulation, minor fixes (#134)
This commit is contained in:
parent
9df0574c4e
commit
9b18587c9e
|
@ -218,7 +218,7 @@ export const AuthorView = (props: AuthorProps) => {
|
||||||
<Switch>
|
<Switch>
|
||||||
<Match when={searchParams().by === 'about'}>
|
<Match when={searchParams().by === 'about'}>
|
||||||
<div class="wide-container">
|
<div class="wide-container">
|
||||||
<p>{author.bio}</p>
|
<p>{author.about}</p>
|
||||||
</div>
|
</div>
|
||||||
</Match>
|
</Match>
|
||||||
<Match when={searchParams().by === 'commented'}>
|
<Match when={searchParams().by === 'commented'}>
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
border: none;
|
border: none;
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
background: url(/public/icons/knowledge-base-bullet.svg) no-repeat;
|
background: url(/icons/knowledge-base-bullet.svg) no-repeat;
|
||||||
content: '';
|
content: '';
|
||||||
height: 2.4rem;
|
height: 2.4rem;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
&:before {
|
&:before {
|
||||||
background-image: url(/public/icons/knowledge-base-bullet-hover.svg);
|
background-image: url(/icons/knowledge-base-bullet-hover.svg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ export const FeedView = () => {
|
||||||
searchParams().by === 'publish_date' || !searchParams().by
|
searchParams().by === 'publish_date' || !searchParams().by
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<a href={getPagePath(router, page().route)}>{t('My feed')}</a>
|
<a href={getPagePath(router, page().route)}>{t('Recent')}</a>
|
||||||
</li>
|
</li>
|
||||||
{/*<li>*/}
|
{/*<li>*/}
|
||||||
{/* <a href="/feed/?by=views">{t('Most read')}</a>*/}
|
{/* <a href="/feed/?by=views">{t('Most read')}</a>*/}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { use as useI18next, init as initI18next } from 'i18next'
|
||||||
import HttpApi from 'i18next-http-backend'
|
import HttpApi from 'i18next-http-backend'
|
||||||
import * as Sentry from '@sentry/browser'
|
import * as Sentry from '@sentry/browser'
|
||||||
import { SENTRY_DSN } from '../utils/config'
|
import { SENTRY_DSN } from '../utils/config'
|
||||||
|
import { resolveHydrationPromise } from '../utils/hydrationPromise'
|
||||||
|
|
||||||
let layoutReady = false
|
let layoutReady = false
|
||||||
|
|
||||||
|
@ -49,3 +50,7 @@ export const render = async (pageContext: PageContextBuiltInClientWithClientRout
|
||||||
layoutReady = true
|
layoutReady = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const onHydrationEnd = () => {
|
||||||
|
resolveHydrationPromise()
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import type { Accessor } from 'solid-js'
|
||||||
import { createRouter, createSearchParams } from '@nanostores/router'
|
import { createRouter, createSearchParams } from '@nanostores/router'
|
||||||
import { isServer } from 'solid-js/web'
|
import { isServer } from 'solid-js/web'
|
||||||
import { useStore } from '@nanostores/solid'
|
import { useStore } from '@nanostores/solid'
|
||||||
|
import { hydrationPromise } from '../utils/hydrationPromise'
|
||||||
|
|
||||||
export const ROUTES = {
|
export const ROUTES = {
|
||||||
home: '/',
|
home: '/',
|
||||||
|
@ -95,6 +96,8 @@ const handleClientRouteLinkClick = async (event) => {
|
||||||
|
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
|
await hydrationPromise
|
||||||
|
|
||||||
if (url.pathname) {
|
if (url.pathname) {
|
||||||
routerStore.open(url.pathname)
|
routerStore.open(url.pathname)
|
||||||
}
|
}
|
||||||
|
|
5
src/utils/hydrationPromise.ts
Normal file
5
src/utils/hydrationPromise.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
export let resolveHydrationPromise
|
||||||
|
|
||||||
|
export const hydrationPromise = new Promise((resolve) => {
|
||||||
|
resolveHydrationPromise = resolve
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user