diff --git a/pages/[...slug].tsx b/pages/[...slug].tsx index 463b2bf0..2eb360b9 100644 --- a/pages/[...slug].tsx +++ b/pages/[...slug].tsx @@ -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,99 +74,110 @@ type Props = { tokens: Token[] } -const Index: NextPage = props => ( - - - {props.title} - {!props.meta ? null : ( - - )} - +const Index: NextPage = props => { + const router = useRouter() + if (router.isFallback) { + return ( +
+ loading... +
+ ) + } - -
- {props.tokens.map((x, i) => { - switch (x.token) { - case 'text': - return ( - - ) + + {props.title} + {!props.meta ? null : ( + + )} + - case 'html': - return ( - - ) - - case 'instagram': - return ( - - ) - - case 'youtube': - return ( - - ) - - case 'image': - return ( -
- {x.data.alt} +
+ {props.tokens.map((x, i) => { + switch (x.token) { + case 'text': + return ( + -
{x.data.caption}
-
- ) + ) - case 'file': - return ( - - ) + case 'html': + return ( + + ) - case 'grid': - return ( - - ) + case 'instagram': + return ( + + ) - default: - return ( -
-                                    {JSON.stringify(x)}
-                                
- ) - } - })} -
-
-
-) + case 'youtube': + return ( + + ) + + case 'image': + return ( +
+ {x.data.alt} +
{x.data.caption}
+
+ ) + + case 'file': + return ( + + ) + + case 'grid': + return ( + + ) + + default: + return ( +
+                                        {JSON.stringify(x)}
+                                    
+ ) + } + })} + + + + ) +} export const getStaticProps: GetStaticProps = async ctx => { const slug = paramsToSlug(ctx.params.slug) @@ -190,6 +202,7 @@ export const getStaticProps: GetStaticProps = 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('/'))