mirror of
https://github.com/skidoodle/albert.lol.git
synced 2025-02-15 06:09:15 +01:00
commit
f001036830
1 changed files with 18 additions and 8 deletions
|
@ -1,7 +1,6 @@
|
|||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import React from "react";
|
||||
import useSWR from "swr";
|
||||
import React, { useEffect } from "react";
|
||||
import FadeIn from "react-fade-in";
|
||||
|
||||
import { socials } from "components/data/socials";
|
||||
|
@ -10,14 +9,14 @@ import { Toaster } from "react-hot-toast";
|
|||
import { FaSpotify } from "react-icons/fa";
|
||||
|
||||
import profilePic from "../public/profile.webp";
|
||||
import { GetServerSideProps } from "next";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
const fetcher = (url: RequestInfo) => fetch(url).then((r) => r.json());
|
||||
export default function ({ spotify }: any) {
|
||||
const { asPath, replace } = useRouter()
|
||||
|
||||
useEffect(() => { replace(asPath) }, [spotify])
|
||||
|
||||
export default function () {
|
||||
const { data: spotify } = useSWR("/api/spotify", fetcher, {
|
||||
refreshInterval: 1000,
|
||||
});
|
||||
if (!spotify) return;
|
||||
return (
|
||||
<FadeIn>
|
||||
<div className="px-8 w-11/12 m-auto rounded-lg max-w-4xl">
|
||||
|
@ -79,3 +78,14 @@ export default function () {
|
|||
</FadeIn>
|
||||
);
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async () => {
|
||||
const { HOST } = process.env
|
||||
|
||||
const res = await fetch(`${HOST}/api/spotify`)
|
||||
const data = await res.json()
|
||||
|
||||
return {
|
||||
props: { spotify: data }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue