Skip to content

Instantly share code, notes, and snippets.

@isilveira1
Last active June 15, 2022 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isilveira1/22f6a40f0de15ea5deb5327a2574fb62 to your computer and use it in GitHub Desktop.
Save isilveira1/22f6a40f0de15ea5deb5327a2574fb62 to your computer and use it in GitHub Desktop.
// This function gets called at build time
export const getStaticPaths: GetStaticPaths = async () => {
// Call an external API endpoint to get dogs
const res = await fetch("https://.../dogs");
const dogs = await res.json();
// Get the paths we want to pre-render based on dogs
const paths = dogs.map((dog: any) => ({
params: { id: dog.id },
}));
// We'll pre-render only these paths at build time.
// { fallback: false } means other routes should 404.
return { paths, fallback: false };
}
export default Doggo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment