import { truncate } from '@/utils/truncate'; import FadeIn from 'react-fade-in'; import Image from 'next/image'; import useSWR from 'swr'; import SongImage from '@/public/song.webp'; import Link from 'next/link'; export const fetcher = (url: RequestInfo) => fetch(url).then((r) => r.json()); export const NowPlayingCard = () => { var { data: spotify } = useSWR('/api/spotify', fetcher, { refreshInterval: 3000, fallbackData: 'loading', }); return (
{spotify.song ? ( Song cover art ) : ( Song cover art )}
Listening to{' '} {spotify.song ? ( {truncate(`${spotify.song.title}`, 20)} ) : ( nothing )}
); };