Advertisement
ziriuz84

Untitled

Oct 9th, 2023
3,193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.08 KB | None | 0 0
  1. ---
  2. import Layout from "../../layouts/Layout.astro";
  3. import { Image } from "astro:assets";
  4.  
  5. export const getStaticPaths = async ({ paginate }) => {
  6.   const FLICKR_API_KEY = process.env.FLICKR_API_KEY;
  7.   const FLICKR_USER_ID = process.env.FLICKR_USER_ID;
  8.   const allPhotos = await fetch(
  9.     `https://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=${FLICKR_API_KEY}&user_id=${FLICKR_USER_ID}&photoset_id=72177720310416326&format=json&nojsoncallback=1`,
  10.  )
  11.    .then((data) => data.json())
  12.    .then((data) => data.photoset.photo);
  13.   console.log(paginate(allPhotos, { pageSize: 6 }));
  14.   return paginate(allPhotos, { pageSize: 6 });
  15. };
  16.  
  17. const { galleryID } = Astro.params;
  18. const { page } = Astro.props;
  19. ---
  20.  
  21. <Layout pageName="gallery" title="Galleria">
  22.   <div
  23.    class="wrapper bg-white bg-opacity-70 w-[97%] mx-auto p-4 box-border rounded flex fex-col items-center flex-wrap"
  24.  >
  25.     <h1 class="text-center text-bold text-4xl w-full">Galleria</h1>
  26.     <div class="gallery flex fex-row justify-between flex-wrap">
  27.       {
  28.         page.data.map((photo: any) => (
  29.           <div class="w-[46%] pb-2 my-4 mx-1 h-46 bg-white flex flex-col rounded justify-between items-center">
  30.             <h2 class="text-center">{photo.title._content}</h2>
  31.             <Image
  32.              src={`https://live.staticflickr.com/${photo.server}/${photo.primary}_${photo.secret}_q.jpg`}
  33.              alt={photo.title._content}
  34.              width="120"
  35.              height="120"
  36.              class="object-cover object-center w-[120px] h-[120px]"
  37.            />
  38.           </div>
  39.         ))
  40.       }
  41.     </div>
  42.     <div class="navigation flex flex-row justify-between w-full">
  43.       {
  44.         page.currentPage > 1 && (
  45.          <a href={page.url.prev} class="text-center text-bold text-2xl">
  46.            Precedente
  47.          </a>
  48.        )
  49.      }
  50.      {
  51.        page.currentPage < page.total - 6 && (
  52.          <a href={page.url.next} class="text-center text-bold text-2xl">
  53.            Successivo
  54.          </a>
  55.        )
  56.      }
  57.    </div>
  58.  </div>
  59. </Layout>
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement