Advertisement
ziriuz84

Untitled

Oct 13th, 2023
923
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.14 KB | None | 0 0
  1. ---
  2. import Layout from "../../layouts/Layout.astro";
  3. import { Image } from "astro:assets";
  4. const FLICKR_API_KEY = process.env.FLICKR_API_KEY;
  5. const FLICKR_USER_ID = process.env.FLICKR_USER_ID;
  6.  
  7. export const getStaticPaths = async ({ paginate }) => {
  8.   const FLICKR_API_KEY = process.env.FLICKR_API_KEY;
  9.   const FLICKR_USER_ID = process.env.FLICKR_USER_ID;
  10.   const allGalleries = await fetch(
  11.     `https://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=${FLICKR_API_KEY}&user_id=${FLICKR_USER_ID}&format=json&nojsoncallback=1`,
  12.  )
  13.    .then((data) => data.json())
  14.    .then((data) => data.photosets.photoset);
  15.   return paginate(allGalleries, { pageSize: 6 });
  16. };
  17.  
  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((gallery) => (
  29.           <a
  30.            href={`/gallery/${gallery.id}/1`}
  31.            class="w-[46%] pb-2 my-4 mx-1 h-46 bg-white flex flex-col rounded justify-between items-center"
  32.          >
  33.             <h2 class="text-center">{gallery.title._content}</h2>
  34.             <Image
  35.              src={`https://live.staticflickr.com/${gallery.server}/${gallery.primary}_${gallery.secret}_q.jpg`}
  36.              alt={gallery.title._content}
  37.              width="120"
  38.              height="120"
  39.              class="object-cover object-center w-[120px] h-[120px]"
  40.            />
  41.           </a>
  42.         ))
  43.       }
  44.     </div>
  45.     <div class="navigation flex flex-row justify-between w-full">
  46.       {
  47.         page.currentPage > 1 && (
  48.          <a href={page.url.prev} class="text-center text-bold text-2xl">
  49.            Precedente
  50.          </a>
  51.        )
  52.      }
  53.      {
  54.        page.currentPage < page.total - 6 && (
  55.          <a href={page.url.next} class="text-center text-bold text-2xl">
  56.            Successivo
  57.          </a>
  58.        )
  59.      }
  60.    </div>
  61.  </div>
  62. </Layout>
  63.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement