Skip to content

Conversation

@antoinekm
Copy link
Contributor

@antoinekm antoinekm commented Mar 14, 2025

Changes

  • Created a new RelatedEvents component that displays events in the same city
  • Updated the event detail page to include the new component
  • Implemented build-time filtering to pre-select related events
  • Only passes necessary event data to each page, not the entire collection

Close: #207
Demo: /events/2025-tunisia-tunis-2

Summary by CodeRabbit

  • New Features
    • Event detail pages now include a "More Events in [city]" section showing up to three related upcoming events in the same city.
    • The related-events section displays as a responsive card grid alongside existing event content and is omitted when no relevant events are found.

@vercel
Copy link

vercel bot commented Mar 14, 2025

@antoinekm is attempting to deploy a commit to the Team Bearstudio Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Mar 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
forkit-community Ready Ready Preview Comment Nov 18, 2025 8:10am

@houssembaltii
Copy link
Contributor

Hello @antoinekm thank you for opening this PR 🙌
Could you please rebase / update it on top of main ?
Thanks a lot!

@antoinekm antoinekm force-pushed the feat/events-from-same-city branch from f7d7983 to 31451df Compare November 6, 2025 22:54
@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Walkthrough

Adds a new RelatedEvents Astro component and integrates it into the event detail page; getStaticPaths now computes up to three related events from the same city (future/near-future, sorted) and passes them to the page, which renders RelatedEvents when data is present.

Changes

Cohort / File(s) Summary
New RelatedEvents Component
src/components/RelatedEvents/index.astro
New component rendering a "More Events in {city}" heading and a responsive grid of TiltedCard-wrapped EventCard items from relatedEvents; returns nothing when relatedEvents is empty or city name is missing.
Event Detail Page Integration
src/pages/events/[id]/index.astro
Imports RelatedEvents. getStaticPaths now computes relatedEvents by filtering other events in the same city with future/near-future dates, sorting by date, and taking up to 3; returns event and relatedEvents in props. Page destructures { event, relatedEvents } and renders <RelatedEvents currentEvent={event} relatedEvents={relatedEvents} />.

Sequence Diagram

sequenceDiagram
    participant Build as Build Time
    participant GetStatic as getStaticPaths()
    participant Filter as RelatedEvent Filter
    participant Page as Event Page
    participant Component as RelatedEvents

    Build->>GetStatic: Generate static paths for events
    GetStatic->>Filter: For each event, find other events in same city
    Filter->>Filter: Exclude current event, filter by date window, sort by date, take up to 3
    Filter->>GetStatic: Return relatedEvents
    GetStatic->>Page: Provide event + relatedEvents props
    Page->>Component: Render RelatedEvents with props
    Component->>Component: Map relatedEvents -> TiltedCard + EventCard
    Component->>Page: Display related events grid
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas to review:
    • getStaticPaths filtering/sorting/date-window logic and correctness
    • Prop typing/usage between index.astro and RelatedEvents component
    • Handling of missing _computed.city.data.name and empty relatedEvents

Poem

🐰 I hopped through events, found three to show,
In the same city where the bright lights glow.
I stacked them in cards, tilted just right,
More nearby stories to read tonight! ✨

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a related events section to the event page.
Linked Issues check ✅ Passed The PR implements the core requirement from issue #207 by creating a RelatedEvents component that displays events in the same city on the event detail page.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the related events feature; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/pages/events/[id]/index.astro (1)

50-59: Consider reversing the sort order to prioritize upcoming events.

The current sorting is ascending (earliest date first), which means past events within the 30-day window will appear before future events. For better user experience, consider showing upcoming events first.

Apply this diff to sort future events first:

       .sort((a, b) => dayjs(a.data.date).diff(dayjs(b.data.date)))
+      .sort((a, b) => {
+        const aDate = dayjs(a.data.date);
+        const bDate = dayjs(b.data.date);
+        const now = dayjs();
+        // Future events first, sorted ascending; then past events, sorted descending
+        const aIsFuture = aDate.isAfter(now);
+        const bIsFuture = bDate.isAfter(now);
+        if (aIsFuture && !bIsFuture) return -1;
+        if (!aIsFuture && bIsFuture) return 1;
+        return aIsFuture ? aDate.diff(bDate) : bDate.diff(aDate);
+      })

Alternatively, for a simpler approach (all events sorted by proximity to today):

-      .sort((a, b) => dayjs(a.data.date).diff(dayjs(b.data.date)))
+      .sort((a, b) => Math.abs(dayjs(a.data.date).diff(dayjs())) - Math.abs(dayjs(b.data.date).diff(dayjs())))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbfcd33 and 31451df.

📒 Files selected for processing (2)
  • src/components/RelatedEvents/index.astro (1 hunks)
  • src/pages/events/[id]/index.astro (2 hunks)
🔇 Additional comments (2)
src/pages/events/[id]/index.astro (1)

43-43: LGTM! Clean integration of the RelatedEvents component.

The import, props destructuring, and component rendering are properly implemented. The placement at the end of the page before the "Join the Community" section is appropriate.

Also applies to: 72-72, 663-664

src/components/RelatedEvents/index.astro (1)

1-12: LGTM! Component setup is clean and well-typed.

The imports and Props interface are properly defined, with appropriate TypeScript types for both currentEvent and relatedEvents.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/components/RelatedEvents/index.astro (1)

14-29: Consider defensive optional chaining on line 18.

While line 15 guards against undefined city names, line 18 accesses currentEvent.data._computed.city.data.name without optional chaining. For defensive coding and future maintainability, consider using optional chaining here as well.

Apply this diff for added safety:

       <h2 class="scroll-mt-32 font-heading text-2xl font-medium uppercase tracking-widest">
-        More Events in {currentEvent.data._computed.city.data.name}
+        More Events in {currentEvent.data._computed.city?.data.name}
       </h2>
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 31451df and 2c0a141.

📒 Files selected for processing (2)
  • src/components/RelatedEvents/index.astro (1 hunks)
  • src/pages/events/[id]/index.astro (2 hunks)
🔇 Additional comments (3)
src/components/RelatedEvents/index.astro (1)

1-12: LGTM! Clean component setup.

The imports, type definitions, and props destructuring follow Astro best practices. The Props interface is properly typed with EventComputed for type safety.

src/pages/events/[id]/index.astro (2)

664-665: LGTM! Clean integration of RelatedEvents component.

The RelatedEvents component is properly integrated with the correct props. The placement at the end of the event page, before the "Join the Community" section, provides good user experience by suggesting related events after users have reviewed the current event details.


50-60: The review comment is incorrect—date field is guaranteed to be defined.

The events collection explicitly excludes sub-pages via its pattern ["**/*.mdx", "!**/pages/*.mdx"] from src/content.config.ts. All main event files in src/content/events/*/index.mdx have the required date field (defined as z.date() in the schema, not optional). The sub-pages found earlier without dates are in a separate eventsSubPages collection and are never included in allEvents.

The code at lines 50–57 correctly filters related events without needing additional null checks for the date field.

Likely an incorrect or invalid review comment.

@antoinekm
Copy link
Contributor Author

Hey ! It should be good now @houssembaltii !

@yoannfleurydev
Copy link
Member

Hi, sorry to ask you this again, but can you rebase it a last time, I will then merge it just after. Thanks a lot 🫶🏻

@yoannfleurydev
Copy link
Member

Done in #495

@antoinekm antoinekm deleted the feat/events-from-same-city branch November 23, 2025 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add next events of the same city on event page

3 participants