|
| 1 | +--- |
| 2 | +import MainLayout from "@/layouts/MainLayout.astro"; |
| 3 | +import MainPageTitle from "@/components/MainPageTitle/index.astro"; |
| 4 | +import { SEO } from "astro-seo"; |
| 5 | +import { getTalksWithVOD } from "@/lib/events"; |
| 6 | +import VideoCard from "@/components/VideoCard/index.astro"; |
| 7 | +import type { GetStaticPathsOptions } from "astro"; |
| 8 | +import { isEmpty } from "remeda"; |
| 9 | +import { cn } from "@/lib/utils-client"; |
| 10 | +import { buttonVariants } from "@/components/ui/button"; |
| 11 | +import { MdArrowBack, MdArrowForward } from "react-icons/md"; |
| 12 | +import TiltedCard from "@/components/TiltedCard"; |
| 13 | +
|
| 14 | +export async function getStaticPaths({ paginate }: GetStaticPathsOptions) { |
| 15 | + const allTalks = await getTalksWithVOD(); |
| 16 | + return paginate(allTalks, { pageSize: 18 }); |
| 17 | +} |
| 18 | +
|
| 19 | +const { page } = Astro.props; |
| 20 | +--- |
| 21 | + |
| 22 | +<MainLayout> |
| 23 | + <SEO |
| 24 | + slot="seo" |
| 25 | + title="Videos" |
| 26 | + description="Catch up on past Fork It! talks" |
| 27 | + noindex={isEmpty(page.data)} |
| 28 | + /> |
| 29 | + <div class="mx-auto w-full max-w-screen-sm px-4"> |
| 30 | + <MainPageTitle |
| 31 | + title="Fork it! Vods" |
| 32 | + subtitle="Watch the community in action" |
| 33 | + blurImage |
| 34 | + /> |
| 35 | + </div> |
| 36 | + <div class="flex flex-1 flex-col"> |
| 37 | + <div class="mx-auto flex w-full max-w-screen-lg flex-col gap-8 px-4 pb-40"> |
| 38 | + { |
| 39 | + page.currentPage !== 1 && ( |
| 40 | + <div class="flex items-center md:col-span-2"> |
| 41 | + <h3 class="text-balance text-sm uppercase tracking-widest opacity-60"> |
| 42 | + Page {page.currentPage} |
| 43 | + </h3> |
| 44 | + <div class="ml-auto flex gap-2"> |
| 45 | + {!!page.url.prev && ( |
| 46 | + <a |
| 47 | + href={page.url.prev} |
| 48 | + class={cn( |
| 49 | + buttonVariants({ size: "xs", variant: "secondary" }), |
| 50 | + "size-8 p-0", |
| 51 | + )} |
| 52 | + > |
| 53 | + <MdArrowBack className="size-4" /> |
| 54 | + <span class="sr-only">Newer videos</span> |
| 55 | + </a> |
| 56 | + )} |
| 57 | + {!!page.url.next && ( |
| 58 | + <a |
| 59 | + href={page.url.next} |
| 60 | + class={cn( |
| 61 | + buttonVariants({ size: "xs", variant: "secondary" }), |
| 62 | + "size-8 p-0", |
| 63 | + )} |
| 64 | + > |
| 65 | + <span class="sr-only">Older videos</span> |
| 66 | + <MdArrowForward className="size-4" /> |
| 67 | + </a> |
| 68 | + )} |
| 69 | + </div> |
| 70 | + </div> |
| 71 | + ) |
| 72 | + } |
| 73 | + |
| 74 | + <section class="space-y-6"> |
| 75 | + <div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-3"> |
| 76 | + { |
| 77 | + page.data.map((talk) => ( |
| 78 | + <TiltedCard client:visible> |
| 79 | + <VideoCard talk={talk} /> |
| 80 | + </TiltedCard> |
| 81 | + )) |
| 82 | + } |
| 83 | + </div> |
| 84 | + </section> |
| 85 | + |
| 86 | + <div class="flex items-center justify-between md:col-span-2"> |
| 87 | + { |
| 88 | + !!page.url.prev && ( |
| 89 | + <a |
| 90 | + href={page.url.prev} |
| 91 | + class={cn(buttonVariants({ variant: "secondary" }), "gap-2")} |
| 92 | + > |
| 93 | + <MdArrowBack /> |
| 94 | + Newer <span class="max-xs:sr-only">videos</span> |
| 95 | + </a> |
| 96 | + ) |
| 97 | + } |
| 98 | + { |
| 99 | + !!page.url.next && ( |
| 100 | + <a |
| 101 | + href={page.url.next} |
| 102 | + class={cn( |
| 103 | + buttonVariants({ variant: "secondary" }), |
| 104 | + "ml-auto gap-2", |
| 105 | + )} |
| 106 | + > |
| 107 | + Older <span class="max-xs:sr-only">videos</span> |
| 108 | + <MdArrowForward /> |
| 109 | + </a> |
| 110 | + ) |
| 111 | + } |
| 112 | + </div> |
| 113 | + </div> |
| 114 | + </div> |
| 115 | +</MainLayout> |
0 commit comments