From b41bead1c840a78c0a15a4892f333f1320de59a0 Mon Sep 17 00:00:00 2001 From: Jorge Vargas Date: Mon, 24 Feb 2025 20:00:31 -0600 Subject: [PATCH] Add pagination to last-added --- src/components/lastAdded/FooterNav.astro | 61 +++++++++++++++++++ src/components/lastAdded/FooterNavItem.astro | 12 ++++ src/pages/404.astro | 4 +- .../{index.astro => [...page].astro} | 28 ++++++++- 4 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 src/components/lastAdded/FooterNav.astro create mode 100644 src/components/lastAdded/FooterNavItem.astro rename src/pages/last-added/{index.astro => [...page].astro} (51%) diff --git a/src/components/lastAdded/FooterNav.astro b/src/components/lastAdded/FooterNav.astro new file mode 100644 index 0000000..ed4f776 --- /dev/null +++ b/src/components/lastAdded/FooterNav.astro @@ -0,0 +1,61 @@ +--- +import FooterNavItem from './FooterNavItem.astro' + +interface Props { + class?: String + fullPageList: number[] + page: number + pageLimit: number +} + +const { class: className, fullPageList, page, pageLimit } = Astro.props +const pageList: number[][] = [[]] + +fullPageList.forEach((n) => { + pageList[pageList.length - 1].push(n) + if (n % pageLimit === 0) pageList.push([]) +}) + +const currentListIndex = pageList.findIndex((l) => l.includes(page)) +const currentList = pageList[currentListIndex] +--- + + diff --git a/src/components/lastAdded/FooterNavItem.astro b/src/components/lastAdded/FooterNavItem.astro new file mode 100644 index 0000000..94e3748 --- /dev/null +++ b/src/components/lastAdded/FooterNavItem.astro @@ -0,0 +1,12 @@ +--- +import type { HTMLAttributes } from 'astro/types' + +interface Props extends HTMLAttributes<'a'> {} +const { class: className, ...attrs } = Astro.props +--- + +
  • + + + +
  • diff --git a/src/pages/404.astro b/src/pages/404.astro index 49cdc03..b441d2a 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -9,8 +9,8 @@ import BaseLayout from '../layouts/base.astro'
    Boat Goes Binted
    -