chore(*): use prettier for formatting
This commit is contained in:
parent
6c659fe1d0
commit
029caaaa9e
73 changed files with 1390 additions and 794 deletions
|
@ -1,26 +1,23 @@
|
|||
import EleventyFetch from "@11ty/eleventy-fetch";
|
||||
import EleventyFetch from '@11ty/eleventy-fetch';
|
||||
|
||||
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
|
||||
|
||||
const fetchAlbumReleases = async () => {
|
||||
try {
|
||||
const data = await EleventyFetch(
|
||||
`${POSTGREST_URL}/optimized_album_releases`,
|
||||
{
|
||||
duration: "1d",
|
||||
type: "json",
|
||||
fetchOptions: {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Bearer ${POSTGREST_API_KEY}`,
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_album_releases`, {
|
||||
duration: '1d',
|
||||
type: 'json',
|
||||
fetchOptions: {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${POSTGREST_API_KEY}`
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const pacificNow = new Date().toLocaleString("en-US", {
|
||||
timeZone: "America/Los_Angeles",
|
||||
const pacificNow = new Date().toLocaleString('en-US', {
|
||||
timeZone: 'America/Los_Angeles'
|
||||
});
|
||||
const pacificDate = new Date(pacificNow);
|
||||
pacificDate.setHours(0, 0, 0, 0);
|
||||
|
@ -32,25 +29,23 @@ const fetchAlbumReleases = async () => {
|
|||
|
||||
return {
|
||||
...album,
|
||||
description: album.artist?.description || "No description",
|
||||
date: releaseDate.toLocaleDateString("en-US", {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
}),
|
||||
description: album.artist?.description || 'No description',
|
||||
date: releaseDate.toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
})
|
||||
};
|
||||
})
|
||||
.sort((a, b) => a.release_timestamp - b.release_timestamp);
|
||||
|
||||
const upcoming = all.filter(
|
||||
(album) =>
|
||||
album.release_timestamp > todayTimestamp &&
|
||||
album.total_plays === 0,
|
||||
(album) => album.release_timestamp > todayTimestamp && album.total_plays === 0
|
||||
);
|
||||
|
||||
return { all, upcoming };
|
||||
} catch (error) {
|
||||
console.error("Error fetching and processing album releases:", error);
|
||||
console.error('Error fetching and processing album releases:', error);
|
||||
return { all: [], upcoming: [] };
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue