diff --git a/.gitignore b/.gitignore
index 48125fa..44490e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,5 @@ node_modules
/build
.vercel
-/support/db/store.db
\ No newline at end of file
+
+/store.db
\ No newline at end of file
diff --git a/static/Gatsby.jpg b/content/posts/images/Gatsby.jpg
similarity index 100%
rename from static/Gatsby.jpg
rename to content/posts/images/Gatsby.jpg
diff --git a/static/david-clode-kuranda.jpg b/content/posts/images/david-clode-kuranda.jpg
similarity index 100%
rename from static/david-clode-kuranda.jpg
rename to content/posts/images/david-clode-kuranda.jpg
diff --git a/static/joel-filipe-white-building.jpg b/content/posts/images/joel-filipe-white-building.jpg
similarity index 100%
rename from static/joel-filipe-white-building.jpg
rename to content/posts/images/joel-filipe-white-building.jpg
diff --git a/static/magnoliajs.png b/content/posts/images/magnoliajs.png
similarity index 100%
rename from static/magnoliajs.png
rename to content/posts/images/magnoliajs.png
diff --git a/static/martin-adams--unsplash.jpg b/content/posts/images/martin-adams--unsplash.jpg
similarity index 100%
rename from static/martin-adams--unsplash.jpg
rename to content/posts/images/martin-adams--unsplash.jpg
diff --git a/static/priscilla-du-preez-FOsina4f7qM-unsplash.jpg b/content/posts/images/priscilla-du-preez-FOsina4f7qM-unsplash.jpg
similarity index 100%
rename from static/priscilla-du-preez-FOsina4f7qM-unsplash.jpg
rename to content/posts/images/priscilla-du-preez-FOsina4f7qM-unsplash.jpg
diff --git a/static/screenshots/fauna-graphql-dashboard.png b/content/posts/images/screenshots/fauna-graphql-dashboard.png
similarity index 100%
rename from static/screenshots/fauna-graphql-dashboard.png
rename to content/posts/images/screenshots/fauna-graphql-dashboard.png
diff --git a/static/screenshots/fauna-security.png b/content/posts/images/screenshots/fauna-security.png
similarity index 100%
rename from static/screenshots/fauna-security.png
rename to content/posts/images/screenshots/fauna-security.png
diff --git a/static/screenshots/gdomains-dns-nameservers.png b/content/posts/images/screenshots/gdomains-dns-nameservers.png
similarity index 100%
rename from static/screenshots/gdomains-dns-nameservers.png
rename to content/posts/images/screenshots/gdomains-dns-nameservers.png
diff --git a/static/steve-harvey-peacock.jpg b/content/posts/images/steve-harvey-peacock.jpg
similarity index 100%
rename from static/steve-harvey-peacock.jpg
rename to content/posts/images/steve-harvey-peacock.jpg
diff --git a/static/unsplash-peacock.jpg b/content/posts/images/unsplash-peacock.jpg
similarity index 100%
rename from static/unsplash-peacock.jpg
rename to content/posts/images/unsplash-peacock.jpg
diff --git a/package.json b/package.json
index 773b24f..5f761c1 100644
--- a/package.json
+++ b/package.json
@@ -14,22 +14,52 @@
"svelte-themer": "next"
},
"devDependencies": {
- "@babel/core": "^7.13.1",
- "@babel/preset-env": "^7.13.5",
+ "@babel/core": "^7.13.14",
+ "@babel/preset-env": "^7.13.12",
"@sveltejs/adapter-static": "next",
"@sveltejs/adapter-vercel": "next",
"@sveltejs/kit": "next",
- "autoprefixer": "^10.2.4",
+ "autoprefixer": "^10.2.5",
+ "eslint": "^7.23.0",
+ "eslint-plugin-svelte3": "^3.1.2",
+ "eslint-config-prettier": "^8.1.0",
"graphql-request": "^3.4.0",
- "postcss": "^8.2.6",
- "postcss-import": "^14.0.0",
- "prettier": "^2.1.2",
- "prettier-plugin-svelte": "^1.4.0",
+ "postcss": "^8.2.9",
+ "postcss-import": "^14.0.1",
+ "prettier": "^2.2.1",
+ "prettier-plugin-svelte": "^2.2.0",
"support": "./support",
"svelte": "^3.29.0",
"svelte-preprocess": "^4.6.6",
"vercel": "^21.3.3",
- "vite": "^2.1.0"
+ "vite": "^2.1.5"
+ },
+ "eslintConfig": {
+ "root": true,
+ "extends": [
+ "eslint:recommended",
+ "prettier"
+ ],
+ "plugins": [
+ "svelte3"
+ ],
+ "overrides": [
+ {
+ "files": [
+ "*.svelte"
+ ],
+ "processor": "svelte3/svelte3"
+ }
+ ],
+ "parserOptions": {
+ "sourceType": "module",
+ "ecmaVersion": 2019
+ },
+ "env": {
+ "browser": true,
+ "es2017": true,
+ "node": true
+ }
},
"prettier": {
"printWidth": 100,
diff --git a/src/hooks.js b/src/hooks.js
new file mode 100644
index 0000000..6c54b18
--- /dev/null
+++ b/src/hooks.js
@@ -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 || [],
+ }
+}
diff --git a/src/pages/$layout.svelte b/src/pages/$layout.svelte
index 7cffb5e..71942e9 100644
--- a/src/pages/$layout.svelte
+++ b/src/pages/$layout.svelte
@@ -94,6 +94,7 @@
:global(body) {
min-height: 100%;
+ display: flex;
}
:global(html, body) {
@@ -101,6 +102,10 @@
background-color: var(--theme-bg);
}
+ :global(#svelte) {
+ flex: 1 1 auto;
+ }
+
:global(*) {
transition-property: background-color;
transition-duration: 200ms;
diff --git a/src/pages/[page].json.js b/src/pages/[page].json.js
deleted file mode 100644
index 2411038..0000000
--- a/src/pages/[page].json.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import { useGraphQL } from '$hooks'
-
-/**
- * @param {import('@sveltejs/kit').Request} request
- * @param {any} context
- * @returns {import('@sveltejs/kit').Response}
- */
-export async function get(req, { api }) {
- const pageQuery = `
- query PAGE($slug: String!) {
- page(slug: $slug) {
- _id
- slug
- frontmatter {
- title
- date
- published
- tags
- }
- html
- }
- }
- `
- const { page: slug } = req.params
- const { data, errors } = await useGraphQL(pageQuery, { slug: `/${slug}` })
- const { page } = data || {}
-
- if (page) {
- return {
- body: {
- page,
- },
- }
- }
-}
diff --git a/src/pages/[page].svelte b/src/pages/[page].svelte
index 1ec089d..b150e38 100644
--- a/src/pages/[page].svelte
+++ b/src/pages/[page].svelte
@@ -1,8 +1,26 @@
diff --git a/src/pages/api/spotify/currently-playing.json.js b/src/pages/api/spotify/currently-playing.json.js
index 5e2a807..6ef7ba7 100644
--- a/src/pages/api/spotify/currently-playing.json.js
+++ b/src/pages/api/spotify/currently-playing.json.js
@@ -24,9 +24,10 @@ export async function get(req) {
const albumImageUrl = song.item.album.images[0].url
const songUrl = song.item.external_urls.spotify
- // res.setHeader('Cache-Control', 'public, s-maxage=60, stale-while-revalidate=30')
-
return {
+ headers: {
+ 'Cache-Control': 'public, s-maxage=60, stale-while-revalidate=30',
+ },
body: {
album,
albumImageUrl,
diff --git a/src/pages/api/spotify/top-tracks.json.js b/src/pages/api/spotify/top-tracks.json.js
new file mode 100644
index 0000000..05e261e
--- /dev/null
+++ b/src/pages/api/spotify/top-tracks.json.js
@@ -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,
+ },
+ }
+}
diff --git a/src/pages/index.svelte b/src/pages/index.svelte
index 7a9ea58..6bdf6d5 100644
--- a/src/pages/index.svelte
+++ b/src/pages/index.svelte
@@ -7,7 +7,8 @@