From e3797e7602f6addb8a6fbe03e18d9bbf5ae8a033 Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Wed, 3 Apr 2024 20:08:46 -0700 Subject: [PATCH] chore: debug --- netlify.toml | 2 ++ plugins/fetch-scrobbles/index.js | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/netlify.toml b/netlify.toml index 178e11b7..46ab0ec9 100644 --- a/netlify.toml +++ b/netlify.toml @@ -8,6 +8,8 @@ [[plugins]] package = "/plugins/fetch-scrobbles" + [plugins.inputs] + dirOutput = "/src/_data/json" ### # URLs diff --git a/plugins/fetch-scrobbles/index.js b/plugins/fetch-scrobbles/index.js index c3a71903..1622c07b 100644 --- a/plugins/fetch-scrobbles/index.js +++ b/plugins/fetch-scrobbles/index.js @@ -1,7 +1,10 @@ import { getStore, setEnvironmentContext } from '@netlify/blobs' import fs from 'fs' -export const onPreBuild = async ({ constants }) => { +export const onPreBuild = async ({ + constants, + inputs: { dirOutput } +}) => { setEnvironmentContext({ siteID: constants.SITE_ID, token: constants.NETLIFY_API_TOKEN, @@ -13,8 +16,8 @@ export const onPreBuild = async ({ constants }) => { const artistsMap = await artists.get('artists-map', { type: 'json' }) const albumsMap = await albums.get('albums-map', { type: 'json' }) const nowPlaying = await scrobbles.get('now-playing', { type: 'json'}) - fs.writeFileSync('/src/_data/json/scrobbles-window.json', JSON.stringify(windowData)) - fs.writeFileSync('/src/_data/json/artists-map.json', JSON.stringify(artistsMap)) - fs.writeFileSync('/src/_data/json/albums-map.json', JSON.stringify(albumsMap)) - fs.writeFileSync('/src/_data/json/now-playing.json', JSON.stringify(nowPlaying)) + fs.writeFileSync(`${dirOutput}scrobbles-window.json`, JSON.stringify(windowData)) + fs.writeFileSync(`${dirOutput}artists-map.json`, JSON.stringify(artistsMap)) + fs.writeFileSync(`${dirOutput}albums-map.json`, JSON.stringify(albumsMap)) + fs.writeFileSync(`${dirOutput}now-playing.json`, JSON.stringify(nowPlaying)) } \ No newline at end of file