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