Initial commit

This commit is contained in:
2023-12-27 15:44:17 +01:00
commit 1f8d8f5b68
31 changed files with 4523 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import { ThemeSwitcher } from '@/components/ThemeSwitcher'
import FadeIn from 'react-fade-in'
import Link from 'next/link'
export default function Error() {
return (
<>
<ThemeSwitcher />
<FadeIn>
<div className='ml-[10%] mr-[10%]'>
<div className='mx-auto mb-16 mt-32 flex max-w-3xl flex-col'>
<h1 className='text-7xl font-bold'>404</h1>
<div className='text-2xl font-semibold text-gray-600'>
<p className='mt-2'>This page could not be found.</p>
<p className='mt-8'>
<Link href='/'>{'<-- Home'}</Link>
</p>
</div>
</div>
</div>
</FadeIn>
</>
)
}
+27
View File
@@ -0,0 +1,27 @@
import { Analytics } from '@vercel/analytics/react'
import { ThemeProvider } from 'next-themes'
import { Inter } from 'next/font/google'
import type { AppProps } from 'next/app'
import '@/styles/globals.scss'
import Head from 'next/head'
const inter = Inter({
subsets: ['latin'],
variable: '--font-inter',
})
export default function App({ Component, pageProps }: AppProps) {
return (
<>
<Head>
<title>albert</title>
</Head>
<main className={`${inter.variable} font-sans`}>
<ThemeProvider>
<Component {...pageProps} />
</ThemeProvider>
</main>
<Analytics />
</>
)
}
+36
View File
@@ -0,0 +1,36 @@
import { Html, Head, Main, NextScript } from 'next/document'
import age from '@/utils/age'
export default function Document() {
return (
<Html lang='zxx'>
<Head>
<meta name='theme-color' content='#121212' />
<meta name='title' content='albert' />
<meta name='og:title' content='albert' />
<meta property='og:url' content='https://albert.lol' />
<link
rel='preconnect'
href='https://vitals.vercel-insights.com'
crossOrigin='anonymous'
/>
<meta
name='description'
content={`${age()}-year-old sysadmin from hungary`}
/>
<meta
name='og:description'
content={`${age()}-year-old sysadmin from hungary`}
/>
<meta
property='og:image'
content='https://cdn.albert.lol/KmxuVVvWGUtGa.webp'
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
+44
View File
@@ -0,0 +1,44 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import { SpotifyService } from '@/service/spotify'
function getEnvVar(key: string): string {
const value = process.env[key]
if (!value) {
throw new Error(`Missing environment variable: ${key}`)
}
return value
}
const CLIENT_ID = getEnvVar('CLIENT_ID')
const CLIENT_SECRET = getEnvVar('CLIENT_SECRET')
const REFRESH_TOKEN = getEnvVar('REFRESH_TOKEN')
const spotify = new SpotifyService(CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN)
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
try {
const song = await spotify.getCurrentSong()
if (!song || !song.isPlaying) {
return res.status(200).json({
nowplaying: false,
})
}
res.status(200).json({
nowplaying: true,
song: {
artist: song.artists.name,
title: song.title,
url: song.url,
image: song.album.image,
progress: song.progress,
},
})
} catch (error) {
res
.status(500)
.json({ error: 'An error occurred while fetching the song.' })
}
}
+27
View File
@@ -0,0 +1,27 @@
import { ThemeSwitcher } from '@/components/ThemeSwitcher'
import { NowPlayingCard } from '@/components/SpotifyCard'
import { SocialLayout } from '@/components/SocialLayout'
import { Toaster } from 'react-hot-toast'
import FadeIn from 'react-fade-in'
import age from '@/utils/age'
export default function Home() {
return (
<>
<ThemeSwitcher />
<FadeIn>
<div className='ml-[10%] mr-[10%]'>
<div className='mx-auto mb-16 mt-32 flex max-w-3xl flex-col'>
<h1 className='text-7xl font-bold'>albert</h1>
<p className='mt-2 text-2xl font-semibold text-gray-600'>
{age()}-year-old sysadmin
</p>
<SocialLayout />
<NowPlayingCard />
<Toaster position='top-left' />
</div>
</div>
</FadeIn>
</>
)
}