File tree Expand file tree Collapse file tree 5 files changed +24
-13
lines changed
Expand file tree Collapse file tree 5 files changed +24
-13
lines changed Original file line number Diff line number Diff line change 1- import SpotifyLogo from '../Spotify/SpotifySvg' ;
21import Line from '../Line' ;
32import { LinkComponent } from '../Typography' ;
4- import { useEffect } from 'react' ;
53import NowPlaying from '../Spotify/NowPlaying' ;
64
75export default function Footer ( ) {
8- useEffect ( ( ) => {
9- fetch ( '/api/fetchCurrentPlayingSong' )
10- . then ( ( response ) => response . json ( ) )
11- . then ( ( response ) => {
12- console . log ( response ) ;
13- } ) ;
14- } , [ ] ) ;
15-
166 return (
177 < footer className = "Footer mt-12" >
188 < Line />
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const apiMap = {
22 SPOTIFY_GET_CURRENT_PLAYING_TRACK :
33 'https://api.spotify.com/v1/me/player/currently-playing' ,
44 SPOTIFY_ACCESS_TOKEN : 'https://accounts.spotify.com/api/token' ,
5+ SPOTIFY_TOP_TRACKS_ENDPOINT : 'https://api.spotify.com/v1/me/top/tracks' ,
56} ;
67
78export default apiMap ;
Original file line number Diff line number Diff line change @@ -17,3 +17,13 @@ export default function AboutPage() {
1717 </ >
1818 ) ;
1919}
20+
21+ // export async function getServerSideProps() {
22+ // const res = await getTopTracks();
23+ // const tracks = await res.json();
24+ // return {
25+ // props: {
26+ // tracks: tracks.items,
27+ // },
28+ // };
29+ // }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import SeoManager from '../../components/SeoManager/SeoManager';
77import { getAllPosts , getPostBySlug } from '../../utils/index' ;
88import { blogFrontMatter } from '../../types/blogfrontMatter' ;
99
10- function BlogPosts ( props : { source : any , frontMatter : blogFrontMatter } ) {
10+ function BlogPosts ( props : { source : any ; frontMatter : blogFrontMatter } ) {
1111 return (
1212 < >
1313 < SeoManager
@@ -29,8 +29,8 @@ export function getStaticPaths() {
2929 } ) ) ;
3030 return {
3131 paths,
32- fallback : false
33- }
32+ fallback : false ,
33+ } ;
3434}
3535
3636export async function getStaticProps ( pageData ) {
Original file line number Diff line number Diff line change @@ -33,3 +33,13 @@ export const getNowPlaying = async () => {
3333 } ,
3434 } ) ;
3535} ;
36+
37+ export const getTopTracks = async ( ) => {
38+ const { access_token } = await getAccessToken ( ) ;
39+
40+ return fetch ( apiMap . SPOTIFY_TOP_TRACKS_ENDPOINT , {
41+ headers : {
42+ Authorization : `Bearer ${ access_token } ` ,
43+ } ,
44+ } ) ;
45+ } ;
You can’t perform that action at this time.
0 commit comments