Add revalidate to static props

This commit is contained in:
Sam Carlton 2021-09-11 15:44:56 -05:00
parent 55c96dbb71
commit c3a58ce424

View file

@ -22,11 +22,17 @@ export async function getStaticPaths() {
} }
} }
const ONE_MINUTE = 60
const defaultStaticProps = {
revalidate: ONE_MINUTE
}
export async function getStaticProps({ params }) { export async function getStaticProps({ params }) {
const { slug } = params const { slug } = params
// if (slug.length > 40 || !TWEET_ID.test(tweet)) { // if (slug.length > 40 || !TWEET_ID.test(tweet)) {
// return { notFound: true }; // return { notFound: true, ...defaultStaticProps };
// } // }
try { try {
@ -57,7 +63,10 @@ export async function getStaticProps({ params }) {
console.log('pageListing', pageListing) console.log('pageListing', pageListing)
return pageListing ? { props: pageListing } : { notFound: true } return pageListing ? {
props: pageListing,
...defaultStaticProps
} : { notFound: true }
} catch (error) { } catch (error) {
// The Twitter API most likely died // The Twitter API most likely died
console.error(error) console.error(error)