From 4a68d4d64a60cd95dbe2802620de7b64626a85ee Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Wed, 21 Feb 2024 09:26:50 -0800 Subject: [PATCH] chore: album releases cleanup --- src/_data/albumReleases.js | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/src/_data/albumReleases.js b/src/_data/albumReleases.js index c79b3670..8b3d3fd0 100644 --- a/src/_data/albumReleases.js +++ b/src/_data/albumReleases.js @@ -5,25 +5,21 @@ import { DateTime } from 'luxon' export default async function () { const URL = process.env.SECRET_FEED_ALBUM_RELEASES const icsToJson = ics.default - if (process.env.ELEVENTY_PRODUCTION) { - const asset = new AssetCache('album_release_data') - if (asset.isCacheValid('1h')) return await asset.getCachedValue() - const icsRes = await fetch(URL) - const icsData = await icsRes.text() - const data = icsToJson(icsData) - const albumReleases = data - .filter((d) => DateTime.fromISO(d.startDate) > DateTime.now()) - .sort((a, b) => new Date(a.startDate) - new Date(b.startDate)) - .map((release) => { - return { - date: release.startDate, - url: release.location, - title: release.summary.replace(/\\/g, ''), - } - }) - await asset.save(albumReleases, 'json') - return albumReleases - } else { - return {} - } + const asset = new AssetCache('album_release_data') + if (asset.isCacheValid('1h')) return await asset.getCachedValue() + const icsRes = await fetch(URL) + const icsData = await icsRes.text() + const data = icsToJson(icsData) + const albumReleases = data + .filter((d) => DateTime.fromISO(d.startDate) > DateTime.now()) + .sort((a, b) => new Date(a.startDate) - new Date(b.startDate)) + .map((release) => { + return { + date: release.startDate, + url: release.location, + title: release.summary.replace(/\\/g, ''), + } + }) + await asset.save(albumReleases, 'json') + return albumReleases }