-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
content updates, migrate to static page data from session
- Loading branch information
Showing
31 changed files
with
773 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ node_modules | |
/build | ||
.vercel | ||
|
||
/support/db/store.db | ||
|
||
/store.db |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import fetch from 'node-fetch' | ||
// import { browser as isBrowser } from '$app/env' | ||
|
||
async function useGraphQL(query, variables) { | ||
const port = 3000 | ||
// const endpoint = isBrowser ? `/graphql` : `http://localhost:${port}/___graphql` | ||
const endpoint = `http://localhost:${port}/___graphql` | ||
const response = await fetch(endpoint, { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ query, variables }), | ||
}) | ||
const parsed = await response.json() | ||
return parsed | ||
} | ||
|
||
/** @type {import('@sveltejs/kit').GetSession} */ | ||
export async function getSession({ context }) { | ||
const postsQuery = ` | ||
query ALL_POSTS { | ||
allPosts(data:{}) { | ||
_id | ||
slug | ||
frontmatter { | ||
title | ||
date | ||
published | ||
tags | ||
} | ||
html | ||
} | ||
} | ||
` | ||
|
||
const pagesQuery = ` | ||
query ALL_PAGES { | ||
allPages { | ||
_id | ||
slug | ||
frontmatter { | ||
title | ||
date | ||
published | ||
tags | ||
} | ||
html | ||
} | ||
} | ||
` | ||
|
||
return { | ||
posts: (await useGraphQL(postsQuery))?.data?.allPosts || [], | ||
pages: (await useGraphQL(pagesQuery))?.data?.allPages || [], | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { getTopTracks } from './_' | ||
|
||
/** | ||
* @param {import('@sveltejs/kit').Request} request | ||
* @param {any} context | ||
* @returns {import('@sveltejs/kit').Response} | ||
*/ | ||
export async function get(req) { | ||
const response = await getTopTracks() | ||
const { items } = await response.json() | ||
|
||
const tracks = items.slice(0, 10).map(track => ({ | ||
artist: track.artists.map(_artist => _artist.name).join(', '), | ||
songUrl: track.external_urls.spotify, | ||
title: track.name, | ||
})) | ||
|
||
// res.setHeader('Cache-Control', 'public, s-maxage=86400, stale-while-revalidate=43200') | ||
|
||
return { | ||
headers: { | ||
'Cache-Control': 'public, s-maxage=86400, stale-while-revalidate=43200', | ||
}, | ||
body: { | ||
tracks, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const { find } = require('../../db') | ||
|
||
module.exports = async function queryAllPages(parent, args, ctx, info) { | ||
return await find({ zone: 'content' }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.