From 463a26defc0d7235cc3ec7711e7cae77f8443c04 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sun, 17 Nov 2024 16:38:19 -0800 Subject: [PATCH] chore: concerts + fix modals --- src/components/blocks/Modal.astro | 29 ++++++++-- src/pages/music/artists/[slug].astro | 49 ++++++++++------ src/pages/music/concerts.astro | 87 ++++++++++++++++++++++++++++ src/styles/base/index.css | 4 +- src/utils/data/concerts.js | 2 +- 5 files changed, 144 insertions(+), 27 deletions(-) create mode 100644 src/pages/music/concerts.astro diff --git a/src/components/blocks/Modal.astro b/src/components/blocks/Modal.astro index 882efd5..7aef463 100644 --- a/src/components/blocks/Modal.astro +++ b/src/components/blocks/Modal.astro @@ -1,8 +1,25 @@ --- -const { content } = Astro.props; ---- +import { md } from "@utils/helpers/general.js"; +import { IconCircleX, IconInfoCircle } from "@tabler/icons-react"; - \ No newline at end of file +const { content, id } = Astro.props; +--- +<> + + + + diff --git a/src/pages/music/artists/[slug].astro b/src/pages/music/artists/[slug].astro index 16fc882..2a6af13 100644 --- a/src/pages/music/artists/[slug].astro +++ b/src/pages/music/artists/[slug].astro @@ -1,5 +1,7 @@ --- +import { DateTime } from "luxon"; import Layout from "@layouts/Layout.astro"; +import Modal from "@components/blocks/Modal.astro"; import ToggleContent from "@components/utils/ToggleContent.astro"; import AssociatedMedia from "@components/blocks/AssociatedMedia.astro"; import { @@ -107,7 +109,6 @@ const playLabel = artist.total_plays === 1 ? "play" : "plays"; ) } - { artist.concerts && ( <> @@ -115,28 +116,38 @@ const playLabel = artist.total_plays === 1 ? "play" : "plays"; I've seen this artist live!

) } - { artist.albums && ( <> diff --git a/src/pages/music/concerts.astro b/src/pages/music/concerts.astro new file mode 100644 index 0000000..69532c4 --- /dev/null +++ b/src/pages/music/concerts.astro @@ -0,0 +1,87 @@ +--- +import Layout from "@layouts/Layout.astro"; +import Paginator from "@components/nav/Paginator.astro"; +import Modal from "@components/blocks/Modal.astro"; +import { fetchConcerts } from "@utils/data/concerts.js"; +import { fetchGlobalData } from "@utils/data/global/index.js"; +import { DateTime } from "luxon"; + +export const prerender = true; + +const { globals } = await fetchGlobalData(Astro); +const concerts = await fetchConcerts(); +const title = "Concerts"; +const description = + "These are concerts I've attended (not all of them — just the ones I could remember or glean from emails, photo metadata et al). I've been to at least " + + concerts.length + + " shows."; +const pageSize = 30; +const currentPage = parseInt(Astro.url.searchParams.get("page") || "1", 10); +const totalPages = Math.ceil(concerts.length / pageSize); +const paginatedConcerts = concerts.slice( + (currentPage - 1) * pageSize, + currentPage * pageSize +); + +const pagination = { + currentPage, + totalPages, + hasPrevious: currentPage > 1, + hasNext: currentPage < totalPages, + previousPage: currentPage > 1 ? `/concerts?page=${currentPage - 1}` : null, + nextPage: currentPage < totalPages ? `/concerts?page=${currentPage + 1}` : null, + pages: Array.from({ length: totalPages }, (_, index) => ({ + number: index + 1, + href: `/concerts?page=${index + 1}`, + })), +}; +--- + + + {currentPage === 1 && ( + <> +

{title}

+

These are concerts I've attended (not all of them — just the ones I could remember or glean from emails, photo metadata et al). I've been to at least {concerts.length} shows.

+
+ + )} + +
    + {paginatedConcerts.map((concert) => ( +
  • + {concert.artist.url ? ( + {concert.artist.name} + ) : ( + {concert.artist.name} + )}{" "} + on{" "} + {DateTime.fromISO(concert.date).toLocaleString(DateTime.DATE_FULL)} + {concert.venue?.name && ( + <> + {" at "} + {concert.venue.latitude && concert.venue.longitude ? ( + {concert.venue.name_short || concert.venue.name} + ) : ( + {concert.venue.name_short || concert.venue.name} + )} + + )} + {concert.notes && ( + + )} +
  • + ))} +
+ + +
diff --git a/src/styles/base/index.css b/src/styles/base/index.css index 1ac2a92..2508a0d 100644 --- a/src/styles/base/index.css +++ b/src/styles/base/index.css @@ -435,12 +435,12 @@ td:first-of-type, main { flex: 1 1 0%; + margin: 0 auto; } main, footer { width: 80%; - margin: var(--sizing-3xl) auto 0; @media screen and (min-width: 768px) { max-width: 768px; @@ -448,6 +448,8 @@ footer { } footer { + margin: var(--sizing-3xl) auto 0; + & nav { &.social, &.sub-pages { diff --git a/src/utils/data/concerts.js b/src/utils/data/concerts.js index 301115f..7b2e64f 100644 --- a/src/utils/data/concerts.js +++ b/src/utils/data/concerts.js @@ -6,7 +6,7 @@ const supabase = createClient(SUPABASE_URL, SUPABASE_KEY); let cachedConcerts = null; -export async function fetchConcertsData() { +export async function fetchConcerts() { if (import.meta.env.MODE === "development" && cachedConcerts) return cachedConcerts;