fallback true; revalidate 30; show simple loader
This commit is contained in:
1 parent
bc07643b11
commit
7d10ea27f0
1 file changed
+15
-2
+15
-2
@@ -15,6 +15,7 @@ import { Youtube } from '@/components/Youtube'
|
||||
import { createPage, createPageUrls } from '@/remote/factory'
|
||||
import { paramsToSlug } from '@/remote/lib'
|
||||
import { PageGrid } from '@/components/PageGrid'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
async function getUrls() {
|
||||
let urls = []
|
||||
@@ -73,7 +74,17 @@ type Props = {
|
||||
tokens: Token[]
|
||||
}
|
||||
|
||||
const Index: NextPage<Props> = props => (
|
||||
const Index: NextPage<Props> = props => {
|
||||
const router = useRouter()
|
||||
if (router.isFallback) {
|
||||
return (
|
||||
<div>
|
||||
loading...
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<App
|
||||
contentStyle={{
|
||||
marginTop: 'var(--size-l)',
|
||||
@@ -166,6 +177,7 @@ const Index: NextPage<Props> = props => (
|
||||
</Page>
|
||||
</App>
|
||||
)
|
||||
}
|
||||
|
||||
export const getStaticProps: GetStaticProps<any> = async ctx => {
|
||||
const slug = paramsToSlug(ctx.params.slug)
|
||||
@@ -190,6 +202,7 @@ export const getStaticProps: GetStaticProps<any> = async ctx => {
|
||||
const tokens = page.tokens
|
||||
|
||||
return {
|
||||
revalidate: 30,
|
||||
props: {
|
||||
tokens,
|
||||
title: page.title,
|
||||
@@ -205,7 +218,7 @@ export const getStaticPaths = async () => {
|
||||
const urls = await getUrls()
|
||||
|
||||
return {
|
||||
fallback: false,
|
||||
fallback: true,
|
||||
paths: urls
|
||||
.map(path => {
|
||||
const slug = tail(path.split('/'))
|
||||
|
||||
Reference in new issue
Block a user