mirror of
https://github.com/skidoodle/albert.lol.git
synced 2025-02-15 06:09:15 +01:00
swr
This commit is contained in:
parent
2b6124cbf9
commit
4deca5056f
4 changed files with 33 additions and 13 deletions
7
components/Loading.tsx
Normal file
7
components/Loading.tsx
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
export const Loading = () => {
|
||||||
|
return(
|
||||||
|
<div className='fixed h-[85vh] w-screen flex justify-center items-center'>
|
||||||
|
<div className='animate-spin w-16 h-16 border-4 border-t-transparent border-l-transparent border-r-black border-b-black dark:border-r-white dark:border-b-white rounded-full' role='status' />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
17
package-lock.json
generated
17
package-lock.json
generated
|
@ -22,6 +22,7 @@
|
||||||
"react-hot-toast": "^2.3.0",
|
"react-hot-toast": "^2.3.0",
|
||||||
"react-icons": "^4.4.0",
|
"react-icons": "^4.4.0",
|
||||||
"sass": "^1.54.4",
|
"sass": "^1.54.4",
|
||||||
|
"swr": "^1.3.0",
|
||||||
"tailwindcss": "^3.1.8",
|
"tailwindcss": "^3.1.8",
|
||||||
"typescript": "4.7.4"
|
"typescript": "4.7.4"
|
||||||
}
|
}
|
||||||
|
@ -1283,6 +1284,15 @@
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/swr": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/swr/-/swr-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-dkghQrOl2ORX9HYrMDtPa7LTVHJjCTeZoB1dqTbnnEDlSvN8JEKpYIYurDfvbQFUUS8Cg8PceFVZNkW0KNNYPw==",
|
||||||
|
"dev": true,
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16.11.0 || ^17.0.0 || ^18.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tailwindcss": {
|
"node_modules/tailwindcss": {
|
||||||
"version": "3.1.8",
|
"version": "3.1.8",
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.1.8.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.1.8.tgz",
|
||||||
|
@ -2203,6 +2213,13 @@
|
||||||
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
|
"integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"swr": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/swr/-/swr-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-dkghQrOl2ORX9HYrMDtPa7LTVHJjCTeZoB1dqTbnnEDlSvN8JEKpYIYurDfvbQFUUS8Cg8PceFVZNkW0KNNYPw==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {}
|
||||||
|
},
|
||||||
"tailwindcss": {
|
"tailwindcss": {
|
||||||
"version": "3.1.8",
|
"version": "3.1.8",
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.1.8.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.1.8.tgz",
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"react-hot-toast": "^2.3.0",
|
"react-hot-toast": "^2.3.0",
|
||||||
"react-icons": "^4.4.0",
|
"react-icons": "^4.4.0",
|
||||||
"sass": "^1.54.4",
|
"sass": "^1.54.4",
|
||||||
|
"swr": "^1.3.0",
|
||||||
"tailwindcss": "^3.1.8",
|
"tailwindcss": "^3.1.8",
|
||||||
"typescript": "4.7.4"
|
"typescript": "4.7.4"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,23 @@
|
||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import useSWR from 'swr'
|
||||||
|
|
||||||
import { socials } from 'components/data/socials'
|
import { socials } from 'components/data/socials'
|
||||||
import { Icon } from 'components/Icon'
|
import { Icon } from 'components/Icon'
|
||||||
import { Footer } from 'components/Footer'
|
import { Footer } from 'components/Footer'
|
||||||
|
import { Loading } from 'components/Loading'
|
||||||
|
|
||||||
import { Toaster } from 'react-hot-toast'
|
import { Toaster } from 'react-hot-toast'
|
||||||
import { FaSpotify } from 'react-icons/fa'
|
import { FaSpotify } from 'react-icons/fa'
|
||||||
|
|
||||||
import { GetServerSideProps } from 'next'
|
const fetcher = (url: RequestInfo) => fetch(url).then(r => r.json())
|
||||||
|
|
||||||
|
export default function() {
|
||||||
|
const { data: spotify } = useSWR('/api/spotify', fetcher)
|
||||||
|
|
||||||
|
if(!spotify) return <Loading />
|
||||||
|
|
||||||
export default function({ spotify }: any) {
|
|
||||||
return(
|
return(
|
||||||
<>
|
<>
|
||||||
<div className='px-8 w-11/12 m-auto rounded-lg max-w-4xl'>
|
<div className='px-8 w-11/12 m-auto rounded-lg max-w-4xl'>
|
||||||
|
@ -39,7 +45,6 @@ export default function({ spotify }: any) {
|
||||||
|
|
||||||
: <a className='text-[#32a866]'> nothing</a>
|
: <a className='text-[#32a866]'> nothing</a>
|
||||||
}
|
}
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -55,13 +60,3 @@ export default function({ spotify }: any) {
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async () => {
|
|
||||||
const spotify = await fetch(`${process.env.PRODUCTION}/api/spotify`, {
|
|
||||||
method: 'GET'
|
|
||||||
}).then((res) => res.json())
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: { spotify }
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue