ebleach7

Untitled

Mar 29th, 2023
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export const getStaticPaths: GetStaticPaths<Params> = async () => {
  2.   const res = await clubService.getClubs();
  3.  
  4.   const paths = res.data.data.map((path) => ({
  5.     params: {
  6.       id: path.id.toString(),
  7.     },
  8.   }));
  9.  
  10.   return {
  11.     paths,
  12.     fallback: false,
  13.   };
  14. };
  15.  
  16. export const getStaticProps: GetStaticProps<IClubData> = async ({
  17.   params,
  18.   locale,
  19. }) => {
  20.   let clubData;
  21.  
  22.   try {
  23.     const clubResponse = await clubService.getClub(Number(params?.id));
  24.     clubData = clubResponse.data.data;
  25.  
  26.     return {
  27.       props: {
  28.         ...(await serverSideTranslations(locale ?? "en", ["common", "header"])),
  29.         club: clubData,
  30.       },
  31.     };
  32.   } catch (error) {
  33.     console.error(error);
  34.  
  35.     return {
  36.       notFound: true,
  37.     };
  38.   }
  39. };
  40.  
  41. export default ClubPage;
Advertisement
Add Comment
Please, Sign In to add comment