Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

getstaticpaths errors after new posts

You can also use getStaticPaths with fallback to true.
And getStaticProps with revalidate whicth triggers incremental builds basiclly.
to avoid error after build
export async function getStaticPaths() {
  const res = await fetch(`${baseUrl}/wp-json/wp/v2/posts`)
  const posts = await res.json()
  const paths = posts.map(({ slug }) => ({ params: { slug: `${slug}` } }))
  return {
    paths,
    fallback: true,
  }
}

export async function getStaticProps(context) {
  const resPost = await fetch(`${baseUrl}/wp-json/wp/v2/posts?slug=${context.params.slug}`)

  const post = await resPost.json()

  return {
    props: {
      post,
    },
    revalidate: 10,
  }
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: stop camera if it hits edge of room gml 
Typescript :: Ignoring ffi-1.15.3 because its extensions are not built 
Typescript :: run build dist in local angualr 
Typescript :: test coverage when tests are in a different package 
Typescript :: stripe create subscription 
Typescript :: multi select 
Typescript :: return n elements from list java 
Typescript :: difference between scripted testing and exploratory testing 
Typescript :: alphabets range using re 
Typescript :: nginx rest api caching 
Typescript :: angular from date to date validation 
Typescript :: typescript type specific strings 
Typescript :: typescript run on save 
Typescript :: promise.all inside useEffect 
Typescript :: regex exec returns null 
Typescript :: pass command line arguments with spaces cmd 
Typescript :: select2 .select2-results .select2-highlighted 
Typescript :: python remove accents pandas 
Typescript :: download blob typescript 
Typescript :: comments tsconfig.json 
Typescript :: connect redis typescript usage 
Typescript :: gatsby typescript starter hello world 
Typescript :: typescript ingerit 
Typescript :: check if all array elements match closure swift 
Typescript :: for (... in ...) statements must be filtered with an if statement (forin) 
Typescript :: import validator adonisjs 5 
Typescript :: the benefits of deploying a network using a WLC 
Typescript :: permalink of pending posts not working 
Typescript :: surround substring with quotes 
Typescript :: angular library dependencies vs peerdependencies 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =