import { useEffect, useRef, useState } from 'react'
import Image from 'next/image'
import { useRouter } from 'next/router'
import Link from 'next/link'
import { useWindowSize } from 'react-use'
import { Swiper, SwiperSlide } from 'swiper/react'
import SwiperCore from 'swiper'
import { Autoplay } from 'swiper/modules'
import 'swiper/css'
import SectionContainer from '../Layouts/SectionContainer'
import { useBreakpoint } from 'common'
import { TweetCard } from 'ui-patterns/TweetCard'
SwiperCore.use([Autoplay])
interface CardInterface {
type: 'twitter' | 'customer-story'
avatar?: string
author: string
role?: string
quote: string | React.ReactNode
abstract?: string
image?: string
url?: string
logo?: string
customer?: string
}
const vectorImagesDir = '/images/product/vector/community/'
const cards: CardInterface[] = [
{
type: 'twitter',
avatar: '',
author: 'Yasser',
quote:
'@kiwicopple @supabase @PostgreSQL @OpenAI Adding vector embeddings support to @Supabase is awesome. Glad I built https://t.co/jnCYOLa4iK on supabase.',
},
{
type: 'customer-story',
avatar: '',
customer: 'Markprompt',
author: 'Michael Fester',
role: 'Co-Founder, Markprompt',
quote:
'We decided to use Supabase over other specialized vector databases because it enabled us to be GDPR compliant from day one with little effort.',
image: vectorImagesDir + 'supabase+firecrawl.svg',
abstract: 'Markprompt and Supabase - GDPR-Compliant AI Chatbots for Docs and Websites.',
url: '/customers/markprompt',
},
{
type: 'customer-story',
avatar: '',
customer: 'Firecrawl',
author: 'Caleb Peffer',
role: 'CEO, Firecrawl',
quote:
'We tried other vector databases - we tried Faiss, we tried Weaviate, we tried Pinecone. We found them to be incredibly expensive and not very intuitive. If you’re just doing vector search they’re great, but if you need to store a bunch of metadata that becomes a huge pain.',
image: vectorImagesDir + 'supabase+markprompt.svg',
abstract: 'Firecrawl switches from Pinecone to Supabase for PostgreSQL vector embeddings.',
url: '/customers/firecrawl',
},
{
type: 'twitter',
avatar: '',
author: 'Batuhan',
quote: (
<>
To create long-term memory for your ChatGPT application you can use @supabase vector
database.
You can fix two common problems with this method:
Global Memory Token Size Limit Handling
>
),
},
]
const CommunitySlider = () => {
const ref = useRef(null)
const isSm = useBreakpoint(768)
const { basePath } = useRouter()
const [swiperInstance, setSwiperInstance] = useState(null)
const { width } = useWindowSize()
useEffect(() => {
// trigger autoplay if viewport resize
if (swiperInstance) swiperInstance?.autoplay?.start()
}, [width])
useEffect(() => {
if (!ref.current || !swiperInstance?.autoplay) return
ref.current?.addEventListener('mouseover', () => swiperInstance?.autoplay?.stop())
ref.current?.addEventListener('mouseleave', () => swiperInstance?.autoplay?.start())
return () => {
ref.current?.removeEventListener('mouseover', () => swiperInstance?.autoplay?.stop())
ref.current?.removeEventListener('mouseleave', () => swiperInstance?.autoplay?.start())
}
}, [ref.current, swiperInstance?.autoplay])
const Card = (card: CardInterface) => (