The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
modify events page to display publish to web events (#43934)
Alan Daniel612d0f366367
diff --git a/apps/www/app/events/context.tsx b/apps/www/app/events/context.tsxindex eddb07b5d23..247d780b228 100644--- a/apps/www/app/events/context.tsx+++ b/apps/www/app/events/context.tsx@@ -4,25 +4,14 @@ import { createContext, useContext, useState, useEffect, useMemo, ReactNode } frimport { SupabaseEvent, SUPABASE_HOST } from '~/lib/eventsTypes'interface EventsContextValue {- // Events dataallEvents: SupabaseEvent[]filteredEvents: SupabaseEvent[]- filteredOnDemandEvents: SupabaseEvent[]- staticEvents: SupabaseEvent[]- onDemandEvents: SupabaseEvent[]- lumaEvents: SupabaseEvent[]featuredEvent: SupabaseEvent | undefined-- // Loading statesisLoading: boolean-- // Search & FiltersearchQuery: stringsetSearchQuery: (query: string) => voidselectedCategories: string[]toggleCategory: (category: string) => void-- // Categoriescategories: { [key: string]: number }}@@ -30,11 +19,10 @@ const EventsContext = createContext<EventsContextValue | undefined>(undefined)interface EventsProviderProps {children: ReactNode- staticEvents: SupabaseEvent[]- onDemandEvents: SupabaseEvent[]+ notionEvents: SupabaseEvent[]}-export function EventsProvider({ children, staticEvents, onDemandEvents }: EventsProviderProps) {+export function EventsProvider({ children, notionEvents }: EventsProviderProps) {const [lumaEvents, setLumaEvents] = useState<SupabaseEvent[]>([])const [isLoading, setIsLoading] = useState(true)const [searchQuery, setSearchQuery] = useState('')@@ -54,10 +42,21 @@ export function EventsProvider({ children, staticEvents, onDemandEvents }: Eventif (data.success) {const transformedEvents: SupabaseEvent[] = data.events.map((event: any) => {- let categories = []+ let categories: string[] = []const isMeetup = event.name.toLowerCase().includes('meetup')if (isMeetup) categories.push('meetup')+ const rawUrl = event?.url || ''+ let safeUrl: string | undefined+ try {+ const parsed = new URL(rawUrl)+ if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {+ safeUrl = rawUrl+ }+ } catch {+ // invalid URL+ }+return {slug: '',type: 'event',@@ -67,7 +66,7 @@ export function EventsProvider({ children, staticEvents, onDemandEvents }: Eventthumb: '',cover_url: event?.cover_url || '',path: '',- url: event?.url || '',+ url: safeUrl ?? '',tags: categories,categories,timezone: event?.timezone || 'America/Los_Angeles',@@ -75,12 +74,9 @@ export function EventsProvider({ children, staticEvents, onDemandEvents }: Event[event?.city, event?.country].filter(Boolean)),hosts: isMeetup || event?.hosts?.length === 0 ? [SUPABASE_HOST] : event?.hosts || [],- source: 'luma',+ source: 'luma' as const,disable_page_build: true,- link: {- href: event?.url || '#',- target: '_blank',- },+ link: safeUrl ? { href: safeUrl, target: '_blank' as const } : undefined,}})setLumaEvents(transformedEvents)@@ -95,37 +91,24 @@ export function EventsProvider({ children, staticEvents, onDemandEvents }: EventfetchLumaEvents()}, [])- // Merge all events (static + luma)+ // Merge Notion (server) + Luma (client) eventsconst allEvents = useMemo(() => {- return [...staticEvents, ...lumaEvents]- }, [staticEvents, lumaEvents])+ return [...notionEvents, ...lumaEvents]+ }, [notionEvents, lumaEvents])- // Calculate categories with counts- // - Webinar: count only upcoming webinars (not on-demand)- // - On-demand: count only on-demand eventsconst categories = useMemo(() => {- const categoryCounts: { [key: string]: number } = { all: 0 }+ const counts: { [key: string]: number } = { all: 0 }- // Count upcoming events (excluding on-demand)allEvents.forEach((event) => {- categoryCounts.all += 1-+ counts.all += 1event.categories?.forEach((category) => {- categoryCounts[category] = (categoryCounts[category] || 0) + 1+ counts[category] = (counts[category] || 0) + 1})})- // Count on-demand events separately- onDemandEvents.forEach((event) => {- categoryCounts.all += 1- // Add to 'on-demand' category instead of 'webinar'- categoryCounts['on-demand'] = (categoryCounts['on-demand'] || 0) + 1- })-- return categoryCounts- }, [allEvents, onDemandEvents])+ return counts+ }, [allEvents])- // Toggle category selectionconst toggleCategory = (category: string) => {if (category === 'all') {setSelectedCategories(['all'])@@ -133,13 +116,10 @@ export function EventsProvider({ children, staticEvents, onDemandEvents }: Event}setSelectedCategories((prev) => {- // Remove 'all' if selecting a specific categoryconst withoutAll = prev.filter((c) => c !== 'all')- // Toggle the categoryif (withoutAll.includes(category)) {const updated = withoutAll.filter((c) => c !== category)- // If no categories selected, default to 'all'return updated.length === 0 ? ['all'] : updated} else {return [...withoutAll, category]@@ -147,23 +127,15 @@ export function EventsProvider({ children, staticEvents, onDemandEvents }: Event})}- // Filter upcoming events by search query and categoryconst filteredEvents = useMemo(() => {- // If 'on-demand' is selected, don't show upcoming events- if (selectedCategories.includes('on-demand') && !selectedCategories.includes('all')) {- return []- }-let filtered = allEvents- // Filter by categories (multiple selection)if (!selectedCategories.includes('all')) {filtered = filtered.filter((event) =>event.categories?.some((cat) => selectedCategories.includes(cat)))}- // Filter by search queryif (searchQuery.trim()) {const query = searchQuery.toLowerCase()filtered = filtered.filter((event) => {@@ -176,46 +148,18 @@ export function EventsProvider({ children, staticEvents, onDemandEvents }: Event})}- // Sort by date (upcoming events first)- return filtered.sort((a, b) => {+ return [...filtered].sort((a, b) => {const dateA = new Date(a.date).getTime()const dateB = new Date(b.date).getTime()- return dateA - dateB+ return dateB - dateA})}, [allEvents, selectedCategories, searchQuery])- // Filter on-demand events separately by search query and category- const filteredOnDemandEvents = useMemo(() => {- // If specific categories are selected (not 'all' and not 'on-demand'), don't show on-demand events- if (!selectedCategories.includes('all') && !selectedCategories.includes('on-demand')) {- return []- }-- let filtered = onDemandEvents-- // Filter by search query- if (searchQuery.trim()) {- const query = searchQuery.toLowerCase()- filtered = filtered.filter((event) => {- const titleMatch = event.title?.toLowerCase().includes(query)- const descriptionMatch = event.description?.toLowerCase().includes(query)- const locationMatch = event.location?.toLowerCase().includes(query)- const tagsMatch = event.tags?.some((tag) => tag.toLowerCase().includes(query))-- return titleMatch || descriptionMatch || locationMatch || tagsMatch- })- }-- return filtered- }, [onDemandEvents, selectedCategories, searchQuery])-- // Featured event: nearest upcoming event, or if none, the most recent past eventconst featuredEvent = useMemo(() => {if (allEvents.length === 0) return undefinedconst now = new Date()- // Separate upcoming and past eventsconst upcomingEvents = allEvents.filter((event) => {const eventDate = new Date(event.end_date || event.date)return eventDate >= now@@ -226,41 +170,29 @@ export function EventsProvider({ children, staticEvents, onDemandEvents }: Eventreturn eventDate < now})- // If there are upcoming events, return the nearest oneif (upcomingEvents.length > 0) {- return upcomingEvents.sort((a, b) => {- const dateA = new Date(a.date).getTime()- const dateB = new Date(b.date).getTime()- return dateA - dateB- })[0]+ return upcomingEvents.sort(+ (a, b) => new Date(a.date).getTime() - new Date(b.date).getTime()+ )[0]}- // If no upcoming events, return the most recent past eventif (pastEvents.length > 0) {- return pastEvents.sort((a, b) => {- const dateA = new Date(a.date).getTime()- const dateB = new Date(b.date).getTime()- return dateB - dateA // Descending order for past events- })[0]+ return pastEvents.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())[0]}return undefined- }, [allEvents, isLoading])+ }, [allEvents])const value: EventsContextValue = {allEvents,filteredEvents,- filteredOnDemandEvents,- staticEvents,- onDemandEvents,- lumaEvents,+ featuredEvent,isLoading,searchQuery,setSearchQuery,selectedCategories,toggleCategory,categories,- featuredEvent,}return <EventsContext.Provider value={value}>{children}</EventsContext.Provider>diff --git a/apps/www/app/events/page.tsx b/apps/www/app/events/page.tsxindex 0d674c52f32..7fe62679651 100644--- a/apps/www/app/events/page.tsx+++ b/apps/www/app/events/page.tsx@@ -1,5 +1,5 @@import type { Metadata } from 'next'-import { getStaticEvents } from '~/lib/events'+import { getNotionEvents } from '~/lib/events'import { EventClientRenderer } from '~/components/Events/new/EventClientRenderer'export const metadata: Metadata = {@@ -9,8 +9,7 @@ export const metadata: Metadata = {}export default async function EventsPage() {- // This needs to be server-side as we use FS api.- const { upcomingEvents, onDemandEvents } = await getStaticEvents()+ const notionEvents = await getNotionEvents()- return <EventClientRenderer staticEvents={upcomingEvents} onDemandEvents={onDemandEvents} />+ return <EventClientRenderer notionEvents={notionEvents} />}diff --git a/apps/www/components/Events/new/EventBanner.tsx b/apps/www/components/Events/new/EventBanner.tsxindex 77b8a05d2bb..6fe96955f07 100644--- a/apps/www/components/Events/new/EventBanner.tsx+++ b/apps/www/components/Events/new/EventBanner.tsx@@ -1,11 +1,10 @@'use client'-import { CalendarIcon, MapPinIcon } from 'lucide-react'-import Image from 'next/image'-import Link from 'next/link'-import { cn, Button, Badge } from 'ui'import { useEvents } from '~/app/events/context'import { formatHosts } from '~/lib/eventsUtils'+import { ArrowRightIcon, CalendarIcon, MapPinIcon } from 'lucide-react'+import Link from 'next/link'+import { Badge, Button } from 'ui'export function EventBanner() {const { isLoading, featuredEvent } = useEvents()@@ -17,15 +16,18 @@ export function EventBanner() {if (!featuredEvent) return nullreturn (- <section- className={cn('grid md:grid-cols-[minmax(320px,35%),1fr] items-start gap-6 lg:gap-12')}- >- <CoverImage url={featuredEvent.cover_url} />-- <article className="flex flex-col md:justify-center gap-6 lg:py-2">- <div className="flex justify-between items-start gap-4">- <div className="flex flex-col gap-1.5">- <h2 className="text-2xl font-medium lg:line-clamp-2">{featuredEvent.title}</h2>+ <section className="flex flex-col gap-6 rounded-lg py-6">+ <article className="flex flex-col md:flex-row md:items-stretch gap-8 lg:py-2">+ <div className="flex flex-col gap-6 flex-1">+ <div className="flex flex-col">+ <div className="flex items-center gap-4">+ <h2 className="text-2xl font-medium lg:line-clamp-2">{featuredEvent.title}</h2>+ {featuredEvent.isSpeaking && (+ <Badge variant="success" className="flex items-center gap-1 shrink-0">+ Speaking+ </Badge>+ )}+ </div><pclassName="text-lg font-medium text-foreground-light"title={`Hosted by ${formatHosts(featuredEvent.hosts).fullList}`}@@ -34,41 +36,38 @@ export function EventBanner() {</p></div>- {featuredEvent.link && (- <Button className="hidden md:block mt-1" size="medium" asChild>- <Link- href={featuredEvent.link.href}- target={featuredEvent.link.target}- rel="noopener noreferrer"- >- Register- </Link>- </Button>- )}- </div>-- <div className="flex flex-wrap gap-y-4 gap-x-12 items-center">- <DateWidget date={featuredEvent.date} endDate={featuredEvent.end_date} />- <LocationWidget location={featuredEvent.location} />- </div>-- <div className="relative flex"><p className="text-foreground-light line-clamp-3 lg:line-clamp-4">{featuredEvent.description}</p></div>- {featuredEvent.link && (- <Button className="block md:hidden mt-1" size="medium" asChild>- <Link- href={featuredEvent.link.href}- target={featuredEvent.link.target}- rel="noopener noreferrer"- >- Register- </Link>- </Button>- )}+ <div className="flex flex-col justify-between gap-8">+ <div className="flex flex-row gap-6">+ <DateWidget date={featuredEvent.date} endDate={featuredEvent.end_date} />+ <LocationWidget location={featuredEvent.location} />+ </div>++ <div className="flex items-center md:justify-end gap-2">+ {featuredEvent.meetingLink && (+ <Button type="secondary" size="medium" asChild>+ <Link href={featuredEvent.meetingLink} target="_blank" rel="noopener noreferrer">+ Meet with us+ </Link>+ </Button>+ )}+ {featuredEvent.link && (+ <Button size="medium" asChild iconRight={<ArrowRightIcon size={14} />}>+ <Link+ href={featuredEvent.link.href}+ target={featuredEvent.link.target}+ rel="noopener noreferrer"+ >+ Register+ </Link>+ </Button>+ )}+ </div>+ </div></article></section>)@@ -76,35 +75,43 @@ export function EventBanner() {const DateWidget = ({ date, endDate }: { date: string; endDate?: string }) => {const eventDate = new Date(date)+ // Date-only Notion events are normalized to noon UTC (T12:00:00Z); detect them+ // so we can display in UTC and suppress the fabricated time component.+ const isDateOnly = date.endsWith('T12:00:00Z')+ const tzOption = isDateOnly ? ({ timeZone: 'UTC' } as const) : {}const formattedDate = eventDate.toLocaleDateString('en-US', {weekday: 'long',month: 'short',day: 'numeric',+ ...tzOption,})const currentYear = new Date().getFullYear()- const eventYear = eventDate.getFullYear()+ const eventYear = isDateOnly ? parseInt(date.slice(0, 4), 10) : eventDate.getFullYear()const formattedDateWithYear =eventYear !== currentYear ? `${formattedDate}, ${eventYear}` : formattedDate- // Extract start time from the date string- const startTime = eventDate.toLocaleTimeString('en-US', {- hour: 'numeric',- minute: '2-digit',- hour12: true,- })-- // If there's an end date, format it and show time range- let timeDisplay = startTime- if (endDate) {- const endEventDate = new Date(endDate)- const endTime = endEventDate.toLocaleTimeString('en-US', {+ // Only show time for events that have a real time component+ let timeDisplay: string | null = null+ if (!isDateOnly) {+ const startTime = eventDate.toLocaleTimeString('en-US', {hour: 'numeric',minute: '2-digit',hour12: true,})- timeDisplay = `${startTime} - ${endTime}`++ if (endDate && !endDate.endsWith('T12:00:00Z')) {+ const endEventDate = new Date(endDate)+ const endTime = endEventDate.toLocaleTimeString('en-US', {+ hour: 'numeric',+ minute: '2-digit',+ hour12: true,+ })+ timeDisplay = `${startTime} - ${endTime}`+ } else {+ timeDisplay = startTime+ }}return (@@ -115,7 +122,7 @@ const DateWidget = ({ date, endDate }: { date: string; endDate?: string }) => {<div className="flex flex-col gap-0"><p>{formattedDateWithYear}</p>- <p className="text-foreground-light text-sm">{timeDisplay}</p>+ {timeDisplay && <p className="text-foreground-light text-sm">{timeDisplay}</p>}</div></div>)@@ -139,125 +146,45 @@ const LocationWidget = ({ location }: { location?: string }) => {)}-const CoverImage = ({ url }: { url?: string }) => {- if (!url)- return (- <div className="w-full bg-surface-100 aspect-square border rounded-lg hidden md:grid place-items-center relative">- <Logo />- <Badge variant="success" className="absolute bottom-4 right-4">- Upcoming- </Badge>- </div>- )-- return (- <div className="w-full bg-surface-100 hidden md:block aspect-square border rounded-lg overflow-hidden relative">- <img src={url} alt="Event Cover" className="object-cover object-center w-full" />- <Badge variant="success" className="absolute bottom-4 right-4">- Upcoming- </Badge>- </div>- )-}--const Logo = () => (- <svg- xmlns="http://www.w3.org/2000/svg"- width="109"- height="113"- fill="none"- viewBox="0 0 109 113"- >- <path- fill="url(#a)"- d="M63.708 110.284c-2.86 3.601-8.658 1.628-8.727-2.97l-1.007-67.251h45.22c8.19 0 12.758 9.46 7.665 15.874z"- ></path>- <path- fill="url(#b)"- fillOpacity="0.2"- d="M63.708 110.284c-2.86 3.601-8.658 1.628-8.727-2.97l-1.007-67.251h45.22c8.19 0 12.758 9.46 7.665 15.874z"- ></path>- <path- fill="#3ecf8e"- d="M45.317 2.071c2.86-3.601 8.657-1.628 8.726 2.97l.442 67.251H9.83c-8.19 0-12.759-9.46-7.665-15.875z"- ></path>- <defs>- <linearGradient- id="a"- x1="53.974"- x2="94.163"- y1="54.974"- y2="71.829"- gradientUnits="userSpaceOnUse"- >- <stop stopColor="#249361"></stop>- <stop offset="1" stopColor="#3ecf8e"></stop>- </linearGradient>- <linearGradient- id="b"- x1="36.156"- x2="54.484"- y1="30.578"- y2="65.081"- gradientUnits="userSpaceOnUse"- >- <stop></stop>- <stop offset="1" stopOpacity="0"></stop>- </linearGradient>- </defs>- </svg>-)-const EventBannerSkeleton = () => {return (- <section className={cn('grid md:grid-cols-[minmax(320px,35%),1fr] gap-12')}>- {/* Cover Image Skeleton */}- <div className="w-full bg-surface-200 aspect-square border rounded-lg animate-pulse" />-- <article className="flex flex-col gap-6 py-2">- <div className="flex justify-between items-start">- <div className="flex flex-col gap-1.5 flex-1">- {/* Title Skeleton */}+ <section className="flex flex-col gap-6 rounded-lg p-6">+ <article className="flex flex-col md:flex-row md:items-stretch gap-6 lg:py-2">+ {/* Left: title + host + description */}+ <div className="flex flex-col gap-6 flex-1">+ <div className="flex flex-col gap-1.5"><div className="h-8 bg-surface-200 rounded animate-pulse w-3/4" />- {/* Host Skeleton */}- <div className="h-6 bg-surface-200 rounded animate-pulse w-1/2 mt-1" />+ <div className="h-5 bg-surface-200 rounded animate-pulse w-1/2 mt-1" /></div>-- {/* Button Skeleton */}- <div className="hidden md:block mt-1 h-10 w-24 bg-surface-200 rounded animate-pulse" />+ <div className="h-16 bg-surface-200 rounded animate-pulse w-full" /></div>- <div className="flex flex-wrap gap-y-4 gap-x-12 items-center">- {/* Date Widget Skeleton */}- <div className="flex items-center gap-4">- <div className="bg-surface-200 p-1.5 border rounded-md">- <div className="size-7 bg-surface-200 rounded animate-pulse" />+ {/* Right: widgets top, button bottom */}+ <div className="flex flex-col justify-between gap-6">+ <div className="flex flex-row gap-6">+ {/* Date Widget Skeleton */}+ <div className="flex items-center gap-4">+ <div className="bg-surface-200 w-10 h-10 rounded-md animate-pulse" />+ <div className="flex flex-col gap-2">+ <div className="h-4 w-32 bg-surface-200 rounded animate-pulse" />+ <div className="h-3 w-20 bg-surface-200 rounded animate-pulse" />+ </div></div>- <div className="flex flex-col gap-2">- <div className="h-5 w-40 bg-surface-200 rounded animate-pulse" />- <div className="h-4 w-24 bg-surface-200 rounded animate-pulse" />+ {/* Location Widget Skeleton */}+ <div className="flex items-center gap-4">+ <div className="bg-surface-200 w-10 h-10 rounded-md animate-pulse" />+ <div className="flex flex-col gap-2">+ <div className="h-4 w-20 bg-surface-200 rounded animate-pulse" />+ <div className="h-3 w-24 bg-surface-200 rounded animate-pulse" />+ </div></div></div>- {/* Location Widget Skeleton */}- <div className="flex items-center gap-4">- <div className="bg-surface-200 p-1.5 border rounded-md">- <div className="size-7 bg-surface-200 rounded animate-pulse" />- </div>- <div className="flex flex-col gap-2">- <div className="h-5 w-24 bg-surface-200 rounded animate-pulse" />- <div className="h-4 w-32 bg-surface-200 rounded animate-pulse" />- </div>+ {/* Button Skeleton */}+ <div className="flex justify-end">+ <div className="h-9 w-24 bg-surface-200 rounded animate-pulse" /></div></div>-- {/* Description Skeleton */}- <div className="mt-4 space-y-2">- <div className="h-32 bg-surface-200 rounded animate-pulse w-full" />- </div>-- {/* Mobile Button Skeleton */}- <div className="block md:hidden mt-1 h-10 w-full bg-surface-200 rounded animate-pulse" /></article></section>)diff --git a/apps/www/components/Events/new/EventClientRenderer.tsx b/apps/www/components/Events/new/EventClientRenderer.tsxindex 248c0b852ee..0642406f108 100644--- a/apps/www/components/Events/new/EventClientRenderer.tsx+++ b/apps/www/components/Events/new/EventClientRenderer.tsx@@ -1,36 +1,40 @@-import { cn } from 'ui'+'use client'++import { EventsProvider, useEvents } from '~/app/events/context'+import { EventBanner } from '~/components/Events/new/EventBanner'import DefaultLayout from '~/components/Layouts/Default'-import SectionContainer from '~/components/Layouts/SectionContainer'-import { getStaticEvents } from '~/lib/events'import { SupabaseEvent } from '~/lib/eventsTypes'-import { EventBanner } from '~/components/Events/new/EventBanner'-import { EventsProvider } from '~/app/events/context'+import { EventGallery } from './EventGallery'+import { EventsContainer } from './EventsContainer'++function EventBannerSection() {+ const { isLoading, featuredEvent } = useEvents()+ if (!isLoading && !featuredEvent) return null++ return (+ <EventsContainer className="border-x border-b flex-1 py-8 bg-surface-200">+ <EventBanner />+ </EventsContainer>+ )+}-export function EventClientRenderer({- staticEvents,- onDemandEvents,-}: {- staticEvents: SupabaseEvent[]- onDemandEvents: SupabaseEvent[]-}) {+export function EventClientRenderer({ notionEvents }: { notionEvents: SupabaseEvent[] }) {return (- <EventsProvider staticEvents={staticEvents} onDemandEvents={onDemandEvents}>+ <EventsProvider notionEvents={notionEvents}><DefaultLayout className="flex flex-col">- <SectionContainer className="border-x border-b !py-8">+ <EventsContainer className="border-x border-b py-8"><h1 className="h3 !p-0 !m-0"><span className="sr-only">Supabase</span> Events</h1><p className="text-foreground-light">Join us at the following upcoming events</p>- </SectionContainer>+ </EventsContainer>- <SectionContainer className="border-x border-b flex-1 !py-8">- <EventBanner />- </SectionContainer>+ <EventBannerSection />- <SectionContainer className="border-x flex-1 !pt-8">+ <EventsContainer className="border-x flex-1 py-8"><EventGallery />- </SectionContainer>+ </EventsContainer></DefaultLayout></EventsProvider>)diff --git a/apps/www/components/Events/new/EventGalleryFilters.tsx b/apps/www/components/Events/new/EventGalleryFilters.tsxindex 85a997686db..06b0a4f2bce 100644--- a/apps/www/components/Events/new/EventGalleryFilters.tsx+++ b/apps/www/components/Events/new/EventGalleryFilters.tsx@@ -7,11 +7,11 @@ import { useEvents } from '~/app/events/context'const CATEGORIES_FILTERS = [{ name: 'All', value: 'all' },+ { name: 'Conference', value: 'conference' },{ name: 'Meetup', value: 'meetup' },{ name: 'Workshop', value: 'workshop' },{ name: 'Hackathon', value: 'hackathon' },{ name: 'Webinar', value: 'webinar' },- { name: 'On demand', value: 'on-demand' },]export function EventGalleryFilters() {diff --git a/apps/www/components/Events/new/EventList.tsx b/apps/www/components/Events/new/EventList.tsxindex 41e4033274f..87e61190c41 100644--- a/apps/www/components/Events/new/EventList.tsx+++ b/apps/www/components/Events/new/EventList.tsx@@ -1,22 +1,22 @@'use client'-import { Rows3Icon } from 'lucide-react'-import Link from 'next/link'-import { Badge, cn } from 'ui'import { useEvents } from '~/app/events/context'import { formatHosts } from '~/lib/eventsUtils'+import { Rows3Icon } from 'lucide-react'+import Link from 'next/link'+import { Badge, Button, cn } from 'ui'const CATEGORIES_FILTERS = [{ name: 'All', value: 'all' },{ name: 'Meetup', value: 'meetup' },+ { name: 'Conference', value: 'conference' },{ name: 'Workshop', value: 'workshop' },{ name: 'Hackathon', value: 'hackathon' },{ name: 'Webinar', value: 'webinar' },- { name: 'On demand', value: 'on-demand' },]export function EventList() {- const { isLoading, filteredEvents, filteredOnDemandEvents } = useEvents()+ const { isLoading, filteredEvents } = useEvents()const getCategoryLabel = (value: string) => {const category = CATEGORIES_FILTERS.find((cat) => cat.value === value)@@ -27,14 +27,16 @@ export function EventList() {return <EventListSkeleton />}- // Group upcoming events by date+ // Group events by dateconst eventsByDate = filteredEvents.reduce((acc, event) => {+ const isDateOnly = event.date.endsWith('T12:00:00Z')const eventDate = new Date(event.date).toLocaleDateString('en-US', {weekday: 'long',year: 'numeric',month: 'long',day: 'numeric',+ ...(isDateOnly ? { timeZone: 'UTC' } : {}),})if (!acc[eventDate]) {@@ -46,8 +48,7 @@ export function EventList() {{} as Record<string, typeof filteredEvents>)- const hasUpcomingEvents = Object.keys(eventsByDate).length > 0- const hasOnDemandEvents = filteredOnDemandEvents.length > 0+ const hasEvents = Object.keys(eventsByDate).length > 0return (<div className="flex flex-col gap-y-8 min-h-72">@@ -68,63 +69,43 @@ export function EventList() {key={`${idx}-${event.url}`}className="bg-surface-100 border rounded-md p-3 flex justify-between items-start relative">- <Link- className="inset-0 absolute"- href={event.url}- target={event.url.startsWith('http') ? '_blank' : '_self'}- title="Go to event page"- aria-hidden- />-- <div className="flex flex-col gap-2">- <h3>{event.title}</h3>-- <div className="flex gap-2 items-center text-sm text-foreground-light">- <div className="size-5 rounded-full border bg-gradient-to-br from-background-surface-100 to-background-surface-200 relative">- {event.hosts[0]?.avatar_url && (- <img- src={event.hosts[0].avatar_url}- alt={event.hosts[0].name || 'Host image'}- className="absolute inset-0 w-full h-full object-cover rounded-full"- />+ {event.url && (+ <Link+ className="inset-0 absolute"+ href={event.url}+ target="_blank"+ rel="noopener noreferrer"+ title="Go to event page"+ aria-hidden+ />+ )}++ <div className="flex flex-col gap-4">+ <div className="flex flex-col gap-2">+ <div className="flex items-center gap-2">+ <h3 className="leading-3">{event.title}</h3>+ {event.isSpeaking && (+ <Badge variant="success" className="flex items-center gap-1">+ Speaking+ </Badge>)}</div>- Hosted by {formatHosts(event.hosts).displayText}- </div>- </div>- {event.categories.map((tag, idx) => (- <Badge key={`tag-${idx}`}>{getCategoryLabel(tag)}</Badge>- ))}- </div>- ))}- </div>- </div>- ))}-- {/* On-demand events section */}- {hasOnDemandEvents && (- <div className="flex flex-col gap-y-2 relative mt-8">- <div className="absolute top-2 -left-[calc(48px+11px)] rounded-full size-1.5 bg-foreground-muted" />-- <h3 className="text-foreground-light font-normal">On Demand</h3>-- <div className="flex flex-col gap-y-4">- {filteredOnDemandEvents.map((event, idx) => (- <div- key={`on-demand-${idx}-${event.url}`}- className="bg-surface-100 border rounded-md p-3 flex justify-between items-start relative"- >- <Link- className="inset-0 absolute"- href={event.url}- target={event.url.startsWith('http') ? '_blank' : '_self'}- title="Go to event page"- aria-hidden- />-- <div className="flex flex-col gap-2">- <h3>{event.title}</h3>+ {event.end_date && (+ <p className="text-xs text-foreground-light">+ {new Date(event.date).toLocaleDateString('en-US', {+ month: 'short',+ day: 'numeric',+ })}+ {' - '}+ {new Date(event.end_date).toLocaleDateString('en-US', {+ month: 'short',+ day: 'numeric',+ year: 'numeric',+ })}+ </p>+ )}+ </div><div className="flex gap-2 items-center text-sm text-foreground-light"><div className="size-5 rounded-full border bg-gradient-to-br from-background-surface-100 to-background-surface-200 relative">@@ -140,17 +121,30 @@ export function EventList() {</div></div>- {event.categories.map((tag, idx) => (- <Badge key={`tag-${idx}`}>{getCategoryLabel(tag)}</Badge>- ))}+ <div className="flex items-center gap-2 relative z-10">+ {event.meetingLink && (+ <Button size="tiny" type="secondary" asChild>+ <Link href={event.meetingLink} target="_blank" rel="noopener noreferrer">+ Meet with us+ </Link>+ </Button>+ )}+ {event.categories.slice(0, 3).map((tag, idx) => (+ <Badge key={`tag-${idx}`}>{getCategoryLabel(tag)}</Badge>+ ))}+ {event.categories.length > 3 && (+ <Badge title={event.categories.slice(3).map(getCategoryLabel).join(', ')}>+ +{event.categories.length - 3}+ </Badge>+ )}+ </div></div>))}</div></div>- )}+ ))}- {/* empty state */}- {!hasUpcomingEvents && !hasOnDemandEvents && (+ {!hasEvents && (<div className="self-center text-muted my-auto flex flex-col items-center gap-y-4"><Rows3Icon className="size-8" /><p className="">Oops! No events found.</p>@@ -167,7 +161,6 @@ const EventListSkeleton = () => {<div key={`skeleton-group-${groupIdx}`} className="flex flex-col gap-y-2 relative"><div className="absolute top-2 -left-[calc(48px+11px)] rounded-full size-1.5 bg-foreground-muted" />- {/* Date Skeleton */}<div className="h-6 bg-surface-200 rounded animate-pulse w-64" /><div className="flex flex-col gap-y-4">@@ -177,17 +170,14 @@ const EventListSkeleton = () => {className="bg-surface-100 border rounded-md p-3 flex justify-between items-start"><div className="flex flex-col gap-2 flex-1">- {/* Title Skeleton */}<div className="h-6 bg-surface-200 rounded animate-pulse w-3/4" />- {/* Host Info Skeleton */}<div className="flex gap-2 items-center"><div className="size-5 rounded-full bg-surface-200 animate-pulse" /><div className="h-4 bg-surface-200 rounded animate-pulse w-32" /></div></div>- {/* Badge Skeleton */}<div className="h-6 w-16 bg-surface-200 rounded-full animate-pulse" /></div>))}diff --git a/apps/www/components/Events/new/EventsContainer.tsx b/apps/www/components/Events/new/EventsContainer.tsxnew file mode 100644index 00000000000..3d779ecbc93--- /dev/null+++ b/apps/www/components/Events/new/EventsContainer.tsx@@ -0,0 +1,14 @@+import { cn } from 'ui'++interface EventsContainerProps {+ children: React.ReactNode+ className?: string+}++export function EventsContainer({ children, className }: EventsContainerProps) {+ return (+ <div className={cn('relative mx-auto w-full max-w-5xl px-4 lg:px-10 xl:px-14', className)}>+ {children}+ </div>+ )+}diff --git a/apps/www/lib/events.ts b/apps/www/lib/events.tsindex db9095fba5c..9deef76277a 100644--- a/apps/www/lib/events.ts+++ b/apps/www/lib/events.ts@@ -1,299 +1,142 @@/** @file events.ts- * @description Unified api to fetch events from Luma and Filesystem.+ * @description Fetch events from the Notion "Developer Events" database.+ * Only events with "Publish to Web" select set to "Yes" are returned.+ *+ * Notion DB schema (actual column names):+ * Event Name -> title+ * Start Date -> date+ * End Date -> date+ * Publish to Web -> select ("Yes" / other)+ * Publish to Web Description -> rich_text+ * URL -> rich_text (event URL)+ * Book Meeting Link -> url+ * Location -> rich_text+ * Category -> multi_select+ * Are you speaking at this event? -> multi_select+ * Participation -> multi_select*/-import supabase from 'lib/supabase'-import { getSortedPosts } from 'lib/posts'-import authors from 'lib/authors.json'-import { EventHost, SUPABASE_HOST, SupabaseEvent } from './eventsTypes'+import { queryDatabase } from 'lib/notion'-/**- * Parse hosts from either a comma-separated string of author IDs or an array of host objects- * Maps author IDs to EventHost objects using the authors.json file- */-function parseHostsFromAuthors(- hostsData?: string | Array<{ name: string; avatar_url?: string | null }>-): EventHost[] {- if (!hostsData) return [SUPABASE_HOST]+import { SUPABASE_HOST, SupabaseEvent } from './eventsTypes'- // Handle array format (new format from MDX files)- if (Array.isArray(hostsData)) {- const hosts = hostsData- .map((host) => {- // Try to find author by name for additional data- const author = authors.find((a: any) => a.author === host.name || a.author_id === host.name)+// The actual DB ID (child database inside the page)+const NOTION_EVENTS_DB_ID_FALLBACK = '21b5004b775f8058872fe8fa81e2c7ac'- if (author) {- return {- id: (author as any).author_id || host.name,- email: (author as any).author_url || '',- name: (author as any).author || host.name,- first_name: (author as any).author?.split(' ')[0] || host.name?.split(' ')[0] || null,- last_name:- (author as any).author?.split(' ').slice(1).join(' ') ||- host.name?.split(' ').slice(1).join(' ') ||- null,- avatar_url: host.avatar_url || (author as any).author_image_url || '',- }- }-- // Return host as-is if no author match- return {- id: host.name,- email: '',- name: host.name,- first_name: host.name?.split(' ')[0] || null,- last_name: host.name?.split(' ').slice(1).join(' ') || null,- avatar_url: host.avatar_url || '',- }- })- .filter((host): host is EventHost => host !== null && host.name !== null)+// ─── Helpers ────────────────────────────────────────────────────────────────- return hosts.length > 0 ? hosts : [SUPABASE_HOST]+function isSafeHttpUrl(url: string): boolean {+ try {+ const parsed = new URL(url)+ return parsed.protocol === 'http:' || parsed.protocol === 'https:'+ } catch {+ return false}+}- // Handle string format (legacy format)- const hostIds = hostsData.split(',').map((id) => id.trim())- const hosts = hostIds- .map((hostId) => {- const author = authors.find((a: any) => a.author_id === hostId)- if (!author) return null-- return {- id: (author as any).author_id || hostId,- email: (author as any).author_url || '',- name: (author as any).author || null,- first_name: (author as any).author?.split(' ')[0] || null,- last_name: (author as any).author?.split(' ').slice(1).join(' ') || null,- avatar_url: (author as any).author_image_url || '',- }- })- .filter((host): host is EventHost => host !== null)-- return hosts.length > 0 ? hosts : [SUPABASE_HOST]+function getTitle(page: any): string {+ const prop = Object.values(page.properties).find((p: any) => p.type === 'title') as any+ return prop?.title?.map((t: any) => t.plain_text).join('') ?? ''}-interface LumaEvent {- id: string- name: string- start_at: string- end_at: string- timezone: string- location: string- url: string- hosts: Array<{- id: string- email: string- name: string | null- first_name: string | null- last_name: string | null- avatar_url: string- }>+function getRichText(page: any, name: string): string {+ const prop = page.properties[name]+ if (!prop || prop.type !== 'rich_text') return ''+ return prop.rich_text.map((t: any) => t.plain_text).join('')}-interface MeetupRecord {- id: string- city: string- country?: string- link: string- start_at: string- timezone: string- launch_week: string+function getUrl(page: any, name: string): string {+ const prop = page.properties[name]+ if (!prop || prop.type !== 'url') return ''+ return prop.url ?? ''}-interface EventRecord {- slug: string- type: string- title: string- date: string- end_date?: string- description: string- thumb: string- cover_url: string- path: string- url: string- tags?: string[]- categories?: string[]- timezone?: string- location?: string- onDemand?: boolean- disable_page_build?: boolean- link?: {- href: string- target?: '_blank' | '_self'- label?: string+function getDate(page: any, name: string): string | null {+ const prop = page.properties[name]+ if (!prop || prop.type !== 'date' || !prop.date) return null+ const raw = prop.date.start ?? null+ if (!raw) return null+ // Normalize date-only strings to noon UTC so the event day displays correctly+ // in all timezones (T00:00:00Z rolls back to the previous day for UTC-negative zones)+ if (/^\d{4}-\d{2}-\d{2}$/.test(raw)) {+ return `${raw}T12:00:00Z`}+ return raw}-/**- * Get the nearest upcoming event from an array of events- * Returns the event with the closest date to now that is still in the future- */-export const getFeaturedEvent = (events: SupabaseEvent[]): SupabaseEvent | null => {- if (!events || events.length === 0) return null-- const now = new Date()-- // Filter for upcoming events only- const upcomingEvents = events.filter((event) => {- const eventDate = new Date(event.end_date || event.date)- return eventDate >= now- })+function getMultiSelect(page: any, name: string): string[] {+ const prop = page.properties[name]+ if (!prop || prop.type !== 'multi_select') return []+ return prop.multi_select.map((s: any) => s.name)+}- if (upcomingEvents.length === 0) return null+// ─── Main fetch ─────────────────────────────────────────────────────────────- // Sort by date ascending and return the nearest one- const sortedEvents = upcomingEvents.sort((a, b) => {- const dateA = new Date(a.date)- const dateB = new Date(b.date)- return dateA.getTime() - dateB.getTime()- })+/**+ * Fetch events from Notion where "Publish to Web" select = "Yes".+ * Returns SupabaseEvent objects sorted by start date ascending.+ */+export const getNotionEvents = async (): Promise<SupabaseEvent[]> => {+ const apiKey = process.env.NOTION_EVENTS_API_KEY+ const dbId = process.env.NOTION_EVENTS_DB_ID_ACTUAL ?? NOTION_EVENTS_DB_ID_FALLBACK- return sortedEvents[0]-}+ if (!apiKey) {+ console.error('NOTION_EVENTS_API_KEY is not set')+ return []+ }-export const getLumaEvents = async (): Promise<SupabaseEvent[]> => {try {- const afterDate = new Date().toISOString()- const url = new URL('/api-v2/luma-events', window.location.origin)- url.searchParams.append('after', afterDate)-- const res = await fetch(url.toString())- const data = await res.json()-- if (data.success) {- const transformedEvents: SupabaseEvent[] = data.events.map((event: LumaEvent) => {- let categories = []- const isMeetup = event.name.toLowerCase().includes('meetup')- if (isMeetup) categories.push('meetup')+ const pages = await queryDatabase(+ dbId,+ apiKey,+ { property: 'Publish to Web', select: { equals: 'Yes' } },+ [{ property: 'Start Date', direction: 'ascending' }]+ )++ return pages+ .map((page): SupabaseEvent | null => {+ const title = getTitle(page)+ const startDate = getDate(page, 'Start Date')+ if (!title || !startDate) return null++ const endDate = getDate(page, 'End Date')+ const description =+ getRichText(page, 'Publish to Web Description') || getRichText(page, 'Notes')+ const rawEventUrl = getRichText(page, 'URL')+ const eventUrl = isSafeHttpUrl(rawEventUrl) ? rawEventUrl : ''+ const rawMeetingLink = getUrl(page, 'Book Meeting Link')+ const meetingLink = isSafeHttpUrl(rawMeetingLink) ? rawMeetingLink : ''+ const location = getRichText(page, 'Location')+ const categories = ['conference']+ const speakingAnswers = getMultiSelect(page, 'Are you speaking at this event?')+ const isSpeaking = speakingAnswers.includes('Yes')return {- slug: '',+ slug: page.id,type: 'event',- title: event?.name || '',- date: event?.start_at || '',- description: '',+ title,+ date: startDate,+ end_date: endDate ?? undefined,+ description,thumb: '',- cover_url: '',+ cover_url: page.cover?.external?.url ?? page.cover?.file?.url ?? '',path: '',- url: event?.url || '',+ url: eventUrl,tags: categories,categories,- timezone: event?.timezone || 'America/Los_Angeles',- location: event?.location || '',- hosts: isMeetup ? [SUPABASE_HOST] : event?.hosts || [],- source: 'luma',+ timezone: '',+ location,+ hosts: [SUPABASE_HOST],+ source: 'notion',disable_page_build: true,- link: {- href: event?.url || '#',- target: '_blank',- },+ isSpeaking,+ meetingLink: meetingLink || undefined,+ link: eventUrl ? { href: eventUrl, target: '_blank' } : undefined,}})- return transformedEvents- }-- return []+ .filter((e): e is SupabaseEvent => e !== null)} catch (error) {- console.error('Error fetching Luma events:', error)+ console.error('Error fetching Notion events:', error)return []}}--export const getStaticEvents = async (): Promise<{- upcomingEvents: SupabaseEvent[]- onDemandEvents: SupabaseEvent[]- categories: { [key: string]: number }-}> => {- const { data: meetups, error } = await supabase- .from('meetups')- .select('id, city, country, link, start_at, timezone, launch_week')- .eq('is_published', true)-- if (error) console.log('meetups error: ', error)-- const meetupEvents: SupabaseEvent[] =- meetups?.map((meetup: any) => ({- slug: '',- type: 'event',- title: `Launch Week ${meetup.launch_week.slice(2)} Meetup: ${meetup.city}, ${meetup.country}`,- date: meetup.start_at,- description: '',- thumb: '',- cover_url: '',- path: '',- url: meetup.link || '',- tags: ['meetup', 'launch-week'],- categories: ['meetup'],- timezone: meetup.timezone || 'America/Los_Angeles',- location: `${meetup.city}, ${meetup.country}`,- hosts: [SUPABASE_HOST],- source: 'supabase',- disable_page_build: true,- link: {- href: meetup.link || '#',- target: '_blank',- },- })) ?? []-- const staticEvents = getSortedPosts({- directory: '_events',- runner: '** EVENTS PAGE **',- })-- const allEvents: SupabaseEvent[] = [- ...staticEvents.map(- (post): SupabaseEvent => ({- slug: post.slug || '',- type: (post as any).type || 'event',- title: post.title || '',- date: post.date || '',- description: post.description || '',- thumb: post.thumb || '',- cover_url: (post as any).cover_url || '',- path: post.path || '',- // For webinars, use internal path; for other events, use external link if available- url:- (post as any).type === 'webinar'- ? post.url || post.path || ''- : post.link?.href || post.url || post.path || '',- tags: post.tags || [],- categories: post.categories || [],- timezone: (post as any).timezone || 'America/Los_Angeles',- location: (post as any).location || '',- hosts: parseHostsFromAuthors((post as any).hosts),- source: 'file',- end_date: (post as any).end_date,- onDemand: (post as any).onDemand,- disable_page_build: (post as any).disable_page_build,- link: (post as any).link,- })- ),- ...meetupEvents,- ]-- const upcomingEvents = allEvents.filter((event: SupabaseEvent) =>- event.end_date ? new Date(event.end_date) >= new Date() : new Date(event.date) >= new Date()- )-- const onDemandEvents = allEvents.filter((event: SupabaseEvent) => event.onDemand === true)-- const categories = upcomingEvents.reduce(- (acc: { [key: string]: number }, event: SupabaseEvent) => {- acc.all = (acc.all || 0) + 1-- event.categories?.forEach((category) => {- acc[category] = (acc[category] || 0) + 1- })-- return acc- },- { all: 0 }- )-- return {- upcomingEvents,- onDemandEvents,- categories,- }-}diff --git a/apps/www/lib/eventsTypes.ts b/apps/www/lib/eventsTypes.tsindex f8cf9f5271e..21b72084156 100644--- a/apps/www/lib/eventsTypes.ts+++ b/apps/www/lib/eventsTypes.ts@@ -45,10 +45,12 @@ export interface SupabaseEvent {timezone: stringlocation: stringhosts: EventHost[]- source: 'luma' | 'supabase' | 'file'+ source: 'luma' | 'notion'end_date?: stringonDemand?: booleandisable_page_build?: boolean+ isSpeaking?: boolean+ meetingLink?: stringlink?: {href: stringtarget?: '_blank' | '_self'diff --git a/apps/www/lib/notion.ts b/apps/www/lib/notion.tsindex 332bb15c0ed..bc46fd54447 100644--- a/apps/www/lib/notion.ts+++ b/apps/www/lib/notion.ts@@ -1,10 +1,56 @@import 'server-only'+const NOTION_VERSION = '2022-06-28'++/**+ * Query a Notion database with optional filter and sorts.+ * Returns the raw array of page objects from the Notion API.+ * Paginates automatically to fetch all matching results.+ */+export const queryDatabase = async (+ dbId: string,+ apiKey: string,+ filter?: Record<string, unknown>,+ sorts?: Array<Record<string, unknown>>+): Promise<any[]> => {+ const pages: any[] = []+ let cursor: string | undefined++ do {+ const body: Record<string, unknown> = {}+ if (filter) body.filter = filter+ if (sorts) body.sorts = sorts+ if (cursor) body.start_cursor = cursor++ const resp = await fetch(`https://api.notion.com/v1/databases/${dbId}/query`, {+ method: 'POST',+ headers: {+ Authorization: `Bearer ${apiKey}`,+ 'Notion-Version': NOTION_VERSION,+ 'Content-Type': 'application/json',+ },+ body: JSON.stringify(body),+ next: { revalidate: 300 }, // cache for 5 minutes+ })++ if (!resp.ok) {+ const text = await resp.text()+ throw new Error(`Failed to query Notion database: ${text}`)+ }++ const data = await resp.json()+ pages.push(...data.results)+ cursor = data.has_more ? data.next_cursor : undefined+ } while (cursor)++ return pages+}+export const getTitlePropertyName = async (dbId: string, apiKey: string): Promise<string> => {const resp = await fetch(`https://api.notion.com/v1/databases/${dbId}`, {headers: {Authorization: `Bearer ${apiKey}`,- 'Notion-Version': '2022-06-28',+ 'Notion-Version': NOTION_VERSION,},})if (!resp.ok) throw new Error('Failed to retrieve database metadata')@@ -23,7 +69,7 @@ export const insertPageInDatabase = async (method: 'POST',headers: {Authorization: `Bearer ${apiKey}`,- 'Notion-Version': '2022-06-28',+ 'Notion-Version': NOTION_VERSION,'Content-Type': 'application/json',},body: JSON.stringify({diff --git a/apps/www/turbo.jsonc b/apps/www/turbo.jsoncindex e6718692a77..deb1af49844 100644--- a/apps/www/turbo.jsonc+++ b/apps/www/turbo.jsonc@@ -72,6 +72,8 @@"CUSTOMERIO_API_KEY","CUSTOMERIO_APP_API_KEY","HUBSPOT_MEETINGS_TOKEN",+ "NOTION_EVENTS_API_KEY",+ "NOTION_EVENTS_DB_ID_ACTUAL",],"outputs": [".next/**", "!.next/cache/**", "!.next/dev/**/*", ".contentlayer/**"],},