This commit is contained in:
arch0Xd 2022-08-14 17:33:43 +02:00
parent 3a92d65900
commit af344d5fcd
32 changed files with 2604 additions and 2724 deletions

View file

@ -1,8 +1,15 @@
import { AppProps } from 'next/app'
import 'styles/globals.scss'
import Head from 'next/head'
const MyApp = ({ Component, pageProps }: AppProps) => {
return <Component {...pageProps} />
}
import { AppProps } from 'next/app'
export default MyApp
export default function({ Component, pageProps }: AppProps) {
return(
<>
<Head>
<title>albert</title>
</Head>
<Component {...pageProps} />
</>
)
}

View file

@ -1,24 +0,0 @@
import { Html, Head, Main, NextScript } from 'next/document'
const Document = () => {
return (
<>
<Html lang='zxx'>
<Head>
<link rel='preconnect' href='https://vitals.vercel-insights.com' />
<link rel='preconnect' href='https://ws.audioscrobbler.com' />
<meta name='title' content='albert' />
<meta name='og:title' content='albert' />
<meta name='description' content='system administrator' />
<meta name='og:description' content='system administrator' />
<meta name='theme-color' content='#000000' />
<meta property='og:image' content='/favicon.ico' />
</Head>
<Main />
<NextScript />
</Html>
</>
)
}
export default Document

39
pages/_error.tsx Normal file
View file

@ -0,0 +1,39 @@
import { GetServerSideProps } from 'next'
type ErrorPage = {
statusCode: number,
message: string
}
export default function({ statusCode, message }: ErrorPage) {
return(
<div className='flex flex-col justify-center items-center h-[90vh]'>
<div>
<h1 className='font-semibold text-2xl inline-block mr-[1.7rem] pr-[1.5rem] border-r-[1px] border-white'>{ statusCode }</h1>
<div className='inline-block text-left'>
<h2 className='text-lg font-extralight'>{ message }</h2>
</div>
</div>
</div>
)
}
export const getServerSideProps: GetServerSideProps = async(props) => {
const { res, err }: any = props
const statusCode = res ? res.statusCode : err ? err.statusCode : 404
var entries: any = {
404: 'Az oldal nem található',
400: 'Érvénytelen kérelem',
500: 'Szerveroldali hiba'
}
const message = entries[statusCode]
return {
props: {
statusCode,
message
}
}
}

View file

@ -1,44 +0,0 @@
import { NextApiRequest, NextApiResponse } from 'next'
import aws from 'aws-sdk'
const { BUCKET, ACCESS_KEY, SECRET_KEY, ENDPOINT, REGION } = process.env
export default async function(req: NextApiRequest, res: NextApiResponse) {
aws.config.s3 = ({
accessKeyId: ACCESS_KEY,
secretAccessKey: SECRET_KEY,
region: REGION,
endpoint: ENDPOINT,
signatureVersion: 'v4'
})
let isTruncated: boolean | undefined = true
let startAfter
let objects = 0
let size = 0
const s3 = new aws.S3()
while(isTruncated) {
let params: any = { Bucket: BUCKET }
if(startAfter) {
params.StartAfter = startAfter
}
const data = await s3.listObjectsV2(params).promise()
data.Contents?.forEach((object: any) => {
objects++
size += object.Size! / 1024 / 1024 / 1024
})
isTruncated = data.IsTruncated
if (isTruncated) {
startAfter = data.Contents!.slice(-1)[0].Key;
}
}
res.setHeader('Cache-Control', 'public, s-maxage=10, stale-while-revalidate=59');
res.json({ object: objects, size: Number(size.toFixed(2)) })
}

28
pages/api/spotify.ts Normal file
View file

@ -0,0 +1,28 @@
import { NextApiRequest, NextApiResponse } from 'next'
export default async function(req: NextApiRequest, res: NextApiResponse) {
// archról másolva: https://github.com/arch0Xd/arch.gay
const { LASTFM_USERNAME, LASTFM_API } = process.env
const { recenttracks: response } = await fetch(`https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=${LASTFM_USERNAME}&api_key=${LASTFM_API}&format=json&limit=1`).then((res) => res.json())
const { track } = response
const { artist, name, url, image } = track[0]
let nowplaying = Boolean(track[0]['@attr']?.nowplaying)
if(nowplaying) {
res.status(200).json({
nowplaying,
song: {
artist: artist['#text'],
title: name,
url: url,
image: image[2]['#text'],
}
})
}
res.status(200).json({ nowplaying })
}

View file

@ -1,52 +1,57 @@
import { GetServerSideProps } from 'next'
import Head from 'next/head'
import FadeIn from 'react-fade-in'
import Body from 'components/Body'
import Icon from 'components/Icon'
import IconLayout from 'components/IconLayout'
import MainLayout from 'components/MainLayout'
import Spotify from 'components/Spotify'
import Weather from 'components/Weather'
import { FaSteam, FaGithub, FaEnvelope } from 'react-icons/fa'
import { RiInstagramFill } from 'react-icons/ri'
import { SiDiscord } from 'react-icons/si'
import dynamic from 'next/dynamic'
const Time = dynamic(() => import('components/Time'), {
ssr: false,
})
import Image from 'next/image'
import React from 'react'
const Home = ({data}: any) => {
return (
import { socials } from 'components/data/socials'
import { Icon } from 'components/Icon'
import { Toaster } from 'react-hot-toast'
import { GetServerSideProps } from 'next'
import { FaSpotify } from 'react-icons/fa'
import { Footer } from 'components/Footer'
export default function({ spotify }: any) {
return(
<>
<Head>
<title>albert</title>
</Head>
<Body>
<FadeIn>
<MainLayout />
<IconLayout>
<Icon icon={<FaGithub />} reference={'https://github.com/skidoodle'} copy={false} />
<Icon icon={<FaSteam />} reference={'https://steamcommunity.com/id/_albert'} copy={false} />
<Icon icon={<FaEnvelope />} reference={'contact@albert.lol'} copy={true} />
<Icon icon={<RiInstagramFill />} reference={'https://instagram.com/albertadam_'} copy={false} />
<Icon icon={<SiDiscord />} reference={'albert#8838'} copy={true} />
</IconLayout>
<Time />
<Weather data={data} />
<Spotify />
</FadeIn>
</Body>
<div className='px-8 w-11/12 m-auto rounded-lg max-w-4xl'>
<div className='flex flex-col justify-center items-center mt-32 md:mt-56'>
<Image src='https://cdn.discordapp.com/avatars/637745537369767936/9cc2e60b7df282b5be9fa701660c651d.webp?size=512' className="rounded-full text-center" height={100} width={100}/>
<h1 className='text-4xl font-bold -mt-1'>albert</h1>
<p className='text-[#9ca3af] text-xl flex flex-wrap items-center justify-center whitespace-pre-wrap'>
{ Math.floor((new Date().getTime() - new Date('2004.07.22').getTime()) / (1000 * 60 * 60 * 24 * 365.25)) }
yrs old <b className='font-semibold'>system administrator</b> and student from <b className='font-bold'>Hungary</b>
</p>
</div>
<hr className='border-t-[#727277] w-4/5 md:w-2/5 m-auto mt-5 md:mt-8'/>
<div className='mt-3 flex justify-center items-center'>
<FaSpotify className='text-[#32a866]' />&nbsp;
<p className='font-semibold'>Listening to
<span className='text-[#32a866]'> { spotify.song?.artist - spotify.song?.title || 'nothing' }</span>
</p>
</div>
<div className='flex justify-between items-center text-3xl mt-11 md:mt-16 max-w-sm m-auto'>
{ socials.map(social => (
<Icon key={ social.id } reference={ social.ref } copyValue={ social.copyValue }>{ React.createElement(social.icon) }</Icon>
))}
</div>
</div>
<Footer />
<Toaster />
</>
)
}
export const getServerSideProps: GetServerSideProps = async () => {
const response = await fetch('https://api.openweathermap.org/data/2.5/weather?lat=47.51&lon=19.04&appid=1b3c10c18e894eaf1fd63eedde53fa54&units=metric')
const data = await response.json()
const spotify = await fetch(`${process.env.PRODUCTION}/api/spotify`, {
method: 'GET'
}).then((res) => res.json())
return {
props: { data }
props: { spotify }
}
}
export default Home
}