From b70828b71eb7914aeec24b45e11d600c554ef9d2 Mon Sep 17 00:00:00 2001 From: Francesco Sansalvadore Date: Mon, 18 Aug 2025 12:02:52 +0200 Subject: [PATCH] remove cms events --- apps/www/pages/events/[slug].tsx | 104 ++++++++++++++++--------------- apps/www/pages/events/index.tsx | 53 ++++++++-------- 2 files changed, 82 insertions(+), 75 deletions(-) diff --git a/apps/www/pages/events/[slug].tsx b/apps/www/pages/events/[slug].tsx index 2825739be18..1ed4450b7b0 100644 --- a/apps/www/pages/events/[slug].tsx +++ b/apps/www/pages/events/[slug].tsx @@ -97,8 +97,9 @@ const EventPage = ({ event }: InferGetStaticPropsType) => export async function getStaticPaths() { const staticPaths = getAllPostSlugs('_events') - const cmsPaths = await getAllCMSEventSlugs() - const paths = [...staticPaths, ...cmsPaths] + // const cmsPaths = await getAllCMSEventSlugs() + // const paths = [...staticPaths, ...cmsPaths] + const paths = [...staticPaths] return { paths, @@ -130,8 +131,9 @@ export const getStaticProps: GetStaticProps = async ({ // Get all posts for navigation and related posts const allStaticEvents = getSortedPosts({ directory: '_events' }) - const allCmsEvents = await getAllCMSEvents() - const allPosts = [...allStaticEvents, ...allCmsEvents].sort( + // const allCmsEvents = await getAllCMSEvents() + // const allPosts = [...allStaticEvents, ...allCmsEvents].sort( + const allPosts = [...allStaticEvents].sort( (a: any, b: any) => new Date(b.date).getTime() - new Date(a.date).getTime() ) const currentIndex = allPosts.findIndex((post) => post.slug === slug) @@ -166,59 +168,61 @@ export const getStaticProps: GetStaticProps = async ({ console.log('[getStaticProps] Static post not found, trying CMS post...') } + return { notFound: true } + // Try CMS post (handle preview/draft logic) - const cmsPost = await getCMSEventBySlug(slug, preview) + // const cmsPost = await getCMSEventBySlug(slug, preview) - if (!cmsPost) { - // Try to fetch published version if preview mode failed - if (preview) { - const publishedPost = await getCMSEventBySlug(slug, false) - if (!publishedPost) { - return { notFound: true } - } - const mdxSource = await mdxSerialize(publishedPost.content || '') + // if (!cmsPost) { + // // Try to fetch published version if preview mode failed + // if (preview) { + // const publishedPost = await getCMSEventBySlug(slug, false) + // if (!publishedPost) { + // return { notFound: true } + // } + // const mdxSource = await mdxSerialize(publishedPost.content || '') - const eventData: Event & EventData = { - ...(publishedPost as any), - tags: publishedPost.tags || [], - authors: publishedPost.authors || [], - isCMS: true, - content: mdxSource, - image: publishedPost.image ?? undefined, - } + // const eventData: Event & EventData = { + // ...(publishedPost as any), + // tags: publishedPost.tags || [], + // authors: publishedPost.authors || [], + // isCMS: true, + // content: mdxSource, + // image: publishedPost.image ?? undefined, + // } - return { - props: { - prevPost: null, - nextPost: null, - relatedPosts: [], - event: eventData, - }, - revalidate: 60 * 10, - } - } - return { notFound: true } - } + // return { + // props: { + // prevPost: null, + // nextPost: null, + // relatedPosts: [], + // event: eventData, + // }, + // revalidate: 60 * 10, + // } + // } + // return { notFound: true } + // } - const mdxSource = await mdxSerialize(cmsPost.content || '') + // const mdxSource = await mdxSerialize(cmsPost.content || '') - const eventData: Event & EventData = { - ...(cmsPost as any), - tags: cmsPost.tags || [], - authors: cmsPost.authors || [], - isCMS: true, - content: mdxSource, - } + // const eventData: Event & EventData = { + // ...(cmsPost as any), + // tags: cmsPost.tags || [], + // authors: cmsPost.authors || [], + // isCMS: true, + // content: mdxSource, + // } - return { - props: { - prevPost: null, - nextPost: null, - relatedPosts: [], - event: eventData, - }, - revalidate: 60 * 10, - } + // return { + // props: { + // prevPost: null, + // nextPost: null, + // relatedPosts: [], + // event: eventData, + // }, + // revalidate: 60 * 10, + // } } export default EventPage diff --git a/apps/www/pages/events/index.tsx b/apps/www/pages/events/index.tsx index 2a3d1deb473..e12ed7b35b9 100644 --- a/apps/www/pages/events/index.tsx +++ b/apps/www/pages/events/index.tsx @@ -22,7 +22,7 @@ interface Props { function Events({ events: staticEvents, onDemandEvents, categories: staticCategories }: Props) { const [lumaEvents, setLumaEvents] = useState([]) - const [cmsEvents, setCmsEvents] = useState([]) + // const [cmsEvents, setCmsEvents] = useState([]) const [events, setEvents] = useState(staticEvents) const router = useRouter() @@ -72,29 +72,31 @@ function Events({ events: staticEvents, onDemandEvents, categories: staticCatego }, []) // Fetch CMS events on client-side - useEffect(() => { - const fetchCmsEvents = async () => { - try { - const url = new URL('/api-v2/cms-events', window.location.origin) - const res = await fetch(url.toString()) - const data = await res.json() - if (data.success && Array.isArray(data.events)) { - setCmsEvents(data.events) - } - } catch (error) { - console.error('Error fetching CMS events:', error) - } - } - fetchCmsEvents() - }, []) + // useEffect(() => { + // const fetchCmsEvents = async () => { + // try { + // const url = new URL('/api-v2/cms-events', window.location.origin) + // const res = await fetch(url.toString()) + // const data = await res.json() + // if (data.success && Array.isArray(data.events)) { + // setCmsEvents(data.events) + // } + // } catch (error) { + // console.error('Error fetching CMS events:', error) + // } + // } + // fetchCmsEvents() + // }, []) // Combine static and Luma events const allEvents = useMemo(() => { - const combined = [...staticEvents, ...cmsEvents, ...lumaEvents] + // const combined = [...staticEvents, ...cmsEvents, ...lumaEvents] + const combined = [...staticEvents, ...lumaEvents] return combined.filter((event: BlogPost) => event.end_date ? new Date(event.end_date!) >= new Date() : new Date(event.date!) >= new Date() ) - }, [staticEvents, cmsEvents, lumaEvents]) + // }, [staticEvents, cmsEvents, lumaEvents]) + }, [staticEvents, lumaEvents]) // Keep displayed events in sync with combined list useEffect(() => { @@ -113,16 +115,17 @@ function Events({ events: staticEvents, onDemandEvents, categories: staticCatego }) }) - cmsEvents.forEach((event) => { - updatedCategories.all = (updatedCategories.all || 0) + 1 + // cmsEvents.forEach((event) => { + // updatedCategories.all = (updatedCategories.all || 0) + 1 - event.categories?.forEach((category) => { - updatedCategories[category] = (updatedCategories[category] || 0) + 1 - }) - }) + // event.categories?.forEach((category) => { + // updatedCategories[category] = (updatedCategories[category] || 0) + 1 + // }) + // }) return updatedCategories - }, [staticCategories, lumaEvents, cmsEvents]) + // }, [staticCategories, lumaEvents, cmsEvents]) + }, [staticCategories, lumaEvents]) const meta_title = 'Supabase Events: webinars, talks, hackathons, and meetups' const meta_description = 'Join Supabase and the open-source community at the upcoming events.'