chore(*): use prettier for formatting

This commit is contained in:
Cory Dransfeldt 2025-06-14 16:43:12 -07:00
parent 6c659fe1d0
commit 029caaaa9e
No known key found for this signature in database
73 changed files with 1390 additions and 794 deletions

View file

@ -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: [] };
}
};

View file

@ -1,27 +1,24 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
export default async function fetchAllActivity() {
try {
const data = await EleventyFetch(
`${POSTGREST_URL}/optimized_all_activity`,
{
duration: "1h",
type: "json",
fetchOptions: {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_all_activity`, {
duration: '1h',
type: 'json',
fetchOptions: {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
);
});
return data?.[0] || [];
} catch (error) {
console.error("Error fetching activity:", error);
console.error('Error fetching activity:', error);
return [];
}
}

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchBlogroll = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_blogroll`, {
duration: "1d",
type: "json",
duration: '1d',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching and processing the blogroll:", error);
console.error('Error fetching and processing the blogroll:', error);
return [];
}
};

View file

@ -1,25 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllBooks = async () => {
try {
return await EleventyFetch(
`${POSTGREST_URL}/optimized_books?order=date_finished.desc`,
{
duration: "1h",
type: "json",
fetchOptions: {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
},
);
return await EleventyFetch(`${POSTGREST_URL}/optimized_books?order=date_finished.desc`, {
duration: '1h',
type: 'json',
fetchOptions: {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching books:", error);
console.error('Error fetching books:', error);
return [];
}
};
@ -45,7 +42,7 @@ export default async function () {
const booksForCurrentYear =
sortedByYear
.find((yearGroup) => yearGroup.value === currentYear)
?.data.filter((book) => book.status === "finished") || [];
?.data.filter((book) => book.status === 'finished') || [];
return {
all: books,

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllConcerts = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_concerts`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching concerts:", error);
console.error('Error fetching concerts:', error);
return [];
}
};
@ -24,7 +24,7 @@ const fetchAllConcerts = async () => {
const processConcerts = (concerts) =>
concerts.map((concert) => ({
...concert,
artist: concert.artist || { name: concert.artist_name_string, url: null },
artist: concert.artist || { name: concert.artist_name_string, url: null }
}));
export default async function () {
@ -32,7 +32,7 @@ export default async function () {
const concerts = await fetchAllConcerts();
return processConcerts(concerts);
} catch (error) {
console.error("Error fetching and processing concerts data:", error);
console.error('Error fetching and processing concerts data:', error);
return [];
}
}

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchFeeds = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_feeds?select=*`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching feed metadata:", error);
console.error('Error fetching feed metadata:', error);
return [];
}
};
@ -24,16 +24,16 @@ const fetchFeeds = async () => {
const fetchFeedData = async (feedKey) => {
try {
return await EleventyFetch(`${POSTGREST_URL}/rpc/get_feed_data`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
},
body: JSON.stringify({ feed_key: feedKey }),
},
body: JSON.stringify({ feed_key: feedKey })
}
});
} catch (error) {
console.error(`Error fetching feed data for ${feedKey}:`, error);
@ -48,9 +48,9 @@ export default async function () {
for (const feed of feeds) {
feedsWithData.push({
...feed,
entries: await fetchFeedData(feed.data),
entries: await fetchFeedData(feed.data)
});
}
return feedsWithData;
};
}

View file

@ -1,27 +1,24 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchGlobals = async () => {
try {
const data = await EleventyFetch(
`${POSTGREST_URL}/optimized_globals?select=*`,
{
duration: "1d",
type: "json",
fetchOptions: {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
},
);
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_globals?select=*`, {
duration: '1d',
type: 'json',
fetchOptions: {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
return data[0];
} catch (error) {
console.error("Error fetching globals:", error);
console.error('Error fetching globals:', error);
return {};
}
};

View file

@ -1,29 +1,31 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
export default async function () {
const res = await EleventyFetch(`${POSTGREST_URL}/optimized_all_tags?order=tag.asc`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
const tags = await res;
const groupedMap = new Map();
for (const tag of tags) {
const letter = /^[a-zA-Z]/.test(tag.tag) ? tag.tag[0].toUpperCase() : "#";
const letter = /^[a-zA-Z]/.test(tag.tag) ? tag.tag[0].toUpperCase() : '#';
if (!groupedMap.has(letter)) groupedMap.set(letter, []);
groupedMap.get(letter).push(tag);
}
return [...groupedMap.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([letter, tags]) => ({ letter, tags: tags.sort((a, b) => a.tag.localeCompare(b.tag)) }));
return [...groupedMap.entries()]
.sort(([a], [b]) => a.localeCompare(b))
.map(([letter, tags]) => ({ letter, tags: tags.sort((a, b) => a.tag.localeCompare(b.tag)) }));
}

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchHeaders = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_headers?select=*`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching header data:", error);
console.error('Error fetching header data:', error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllLinks = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_links?select=*`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching links:", error);
console.error('Error fetching links:', error);
return [];
}
};
@ -26,6 +26,6 @@ export default async function () {
return {
all: links,
feed: links.filter((links) => links.feed),
}
feed: links.filter((links) => links.feed)
};
}

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllMovies = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_movies?select=*`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching movies:", error);
console.error('Error fetching movies:', error);
return [];
}
};
@ -44,19 +44,17 @@ export default async function () {
movies,
watchHistory: movies.filter((movie) => movie.last_watched),
recentlyWatched: recentlyWatchedMovies,
favorites: favoriteMovies.sort((a, b) =>
a.title.localeCompare(b.title),
),
feed: movies.filter((movie) => movie.feed),
favorites: favoriteMovies.sort((a, b) => a.title.localeCompare(b.title)),
feed: movies.filter((movie) => movie.feed)
};
} catch (error) {
console.error("Error fetching and processing movies data:", error);
console.error('Error fetching and processing movies data:', error);
return {
movies: [],
watchHistory: [],
recentlyWatched: [],
favorites: [],
feed: [],
feed: []
};
}
}

View file

@ -1,19 +1,19 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchDataFromView = async (viewName) => {
try {
return await EleventyFetch(`${POSTGREST_URL}/${viewName}?select=*`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error(`Error fetching data from view ${viewName}:`, error);
@ -32,17 +32,17 @@ export default async function fetchMusicData() {
monthTracks,
monthArtists,
monthAlbums,
monthGenres,
monthGenres
] = await Promise.all([
fetchDataFromView("recent_tracks"),
fetchDataFromView("week_tracks"),
fetchDataFromView("week_artists"),
fetchDataFromView("week_albums"),
fetchDataFromView("week_genres"),
fetchDataFromView("month_tracks"),
fetchDataFromView("month_artists"),
fetchDataFromView("month_albums"),
fetchDataFromView("month_genres"),
fetchDataFromView('recent_tracks'),
fetchDataFromView('week_tracks'),
fetchDataFromView('week_artists'),
fetchDataFromView('week_albums'),
fetchDataFromView('week_genres'),
fetchDataFromView('month_tracks'),
fetchDataFromView('month_artists'),
fetchDataFromView('month_albums'),
fetchDataFromView('month_genres')
]);
return {
@ -52,9 +52,7 @@ export default async function fetchMusicData() {
artists: weekArtists,
albums: weekAlbums,
genres: weekGenres,
totalTracks: weekTracks
.reduce((acc, track) => acc + track.plays, 0)
.toLocaleString("en-US"),
totalTracks: weekTracks.reduce((acc, track) => acc + track.plays, 0).toLocaleString('en-US')
},
month: {
tracks: monthTracks,
@ -63,11 +61,11 @@ export default async function fetchMusicData() {
genres: monthGenres,
totalTracks: monthTracks
.reduce((acc, track) => acc + track.plays, 0)
.toLocaleString("en-US"),
},
.toLocaleString('en-US')
}
};
} catch (error) {
console.error("Error fetching and processing music data:", error);
console.error('Error fetching and processing music data:', error);
return {
recent: [],
week: {
@ -75,15 +73,15 @@ export default async function fetchMusicData() {
artists: [],
albums: [],
genres: [],
totalTracks: "0",
totalTracks: '0'
},
month: {
tracks: [],
artists: [],
albums: [],
genres: [],
totalTracks: "0",
},
totalTracks: '0'
}
};
}
}

View file

@ -1,23 +1,20 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllNavigation = async () => {
try {
const data = await EleventyFetch(
`${POSTGREST_URL}/optimized_navigation?select=*`,
{
duration: "1d",
type: "json",
fetchOptions: {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
},
);
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_navigation?select=*`, {
duration: '1d',
type: 'json',
fetchOptions: {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
const nav = data.reduce((acc, item) => {
const navItem = {
@ -25,7 +22,7 @@ const fetchAllNavigation = async () => {
permalink: item.permalink || item.page_permalink,
icon: item.icon,
section: item.section,
sort: item.sort,
sort: item.sort
};
if (!acc[item.menu_location]) {
@ -43,7 +40,7 @@ const fetchAllNavigation = async () => {
return nav;
} catch (error) {
console.error("Error fetching navigation data:", error);
console.error('Error fetching navigation data:', error);
return {};
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllPages = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_pages?select=*`, {
duration: "1d",
type: "json",
duration: '1d',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching pages:", error);
console.error('Error fetching pages:', error);
return [];
}
};

View file

@ -1,25 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllPosts = async () => {
try {
return await EleventyFetch(
`${POSTGREST_URL}/optimized_posts?select=*&order=date.desc`,
{
duration: "1d",
type: "json",
fetchOptions: {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
},
);
return await EleventyFetch(`${POSTGREST_URL}/optimized_posts?select=*&order=date.desc`, {
duration: '1d',
type: 'json',
fetchOptions: {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching posts:", error);
console.error('Error fetching posts:', error);
return [];
}
};
@ -29,6 +26,6 @@ export default async function () {
return {
all: posts,
feed: posts.filter((posts) => posts.feed),
feed: posts.filter((posts) => posts.feed)
};
}

View file

@ -1,29 +1,26 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
export default async function () {
try {
const data = await EleventyFetch(
`${POSTGREST_URL}/optimized_recent_activity`,
{
duration: "1h",
type: "json",
fetchOptions: {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_recent_activity`, {
duration: '1h',
type: 'json',
fetchOptions: {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
);
});
const feeds = data?.[0]?.feed || [];
return feeds.filter((item) => item !== null);
} catch (error) {
console.error("Error fetching recent activity:", error);
console.error('Error fetching recent activity:', error);
return [];
}
}

View file

@ -1,25 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchRedirects = async () => {
try {
return await EleventyFetch(
`${POSTGREST_URL}/optimized_redirects?select=*`,
{
duration: "1h",
type: "json",
fetchOptions: {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
},
);
return await EleventyFetch(`${POSTGREST_URL}/optimized_redirects?select=*`, {
duration: '1h',
type: 'json',
fetchOptions: {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching redirect data:", error);
console.error('Error fetching redirect data:', error);
return [];
}
};

View file

@ -1,33 +1,30 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllRobots = async () => {
try {
const data = await EleventyFetch(
`${POSTGREST_URL}/optimized_robots?select=path,user_agents`,
{
duration: "1h",
type: "json",
fetchOptions: {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
},
);
const data = await EleventyFetch(`${POSTGREST_URL}/optimized_robots?select=path,user_agents`, {
duration: '1h',
type: 'json',
fetchOptions: {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
const sortedData = data.sort((a, b) => {
const aHasWildcard = a.user_agents.includes("*") ? 0 : 1;
const bHasWildcard = b.user_agents.includes("*") ? 0 : 1;
const aHasWildcard = a.user_agents.includes('*') ? 0 : 1;
const bHasWildcard = b.user_agents.includes('*') ? 0 : 1;
return aHasWildcard - bHasWildcard || a.path.localeCompare(b.path);
});
return sortedData;
} catch (error) {
console.error("Error fetching robot data:", error);
console.error('Error fetching robot data:', error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchSitemap = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_sitemap?select=*`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching sitemap entries:", error);
console.error('Error fetching sitemap entries:', error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchStats = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_stats?select=*`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching stats data:", error);
console.error('Error fetching stats data:', error);
return [];
}
};

View file

@ -1,4 +1,4 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
@ -7,21 +7,21 @@ const fetchTopAlbums = async () => {
const data = await EleventyFetch(
`${POSTGREST_URL}/optimized_albums?select=table&order=total_plays_raw.desc&limit=8`,
{
duration: "1d",
type: "json",
duration: '1d',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
}
);
return data;
} catch (error) {
console.error("Error fetching top albums:", error);
console.error('Error fetching top albums:', error);
return {};
}
};

View file

@ -1,4 +1,4 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
@ -7,21 +7,21 @@ const fetchTopArtists = async () => {
const data = await EleventyFetch(
`${POSTGREST_URL}/optimized_artists?select=table&order=total_plays_raw.desc&limit=8`,
{
duration: "1d",
type: "json",
duration: '1d',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
}
);
return data;
} catch (error) {
console.error("Error fetching top artists:", error);
console.error('Error fetching top artists:', error);
return {};
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchTopTags = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/rpc/get_top_tag_groups`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "POST",
method: 'POST',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching top tag entries:", error);
console.error('Error fetching top tag entries:', error);
return [];
}
};

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchAllShows = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_shows?select=*`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching shows:", error);
console.error('Error fetching shows:', error);
return [];
}
};
@ -25,9 +25,7 @@ export default async function () {
try {
const shows = await fetchAllShows();
const watchedShows = shows.filter(
(show) => show.last_watched_at !== null,
);
const watchedShows = shows.filter((show) => show.last_watched_at !== null);
const episodes = watchedShows.map((show) => ({
title: show.episode.title,
@ -37,7 +35,7 @@ export default async function () {
image: show.episode.image,
backdrop: show.episode.backdrop,
last_watched_at: show.episode.last_watched_at,
grid: show.grid,
grid: show.grid
}));
return {
@ -45,15 +43,15 @@ export default async function () {
recentlyWatched: episodes.slice(0, 125),
favorites: shows
.filter((show) => show.favorite)
.sort((a, b) => a.title.localeCompare(b.title)),
.sort((a, b) => a.title.localeCompare(b.title))
};
} catch (error) {
console.error("Error fetching and processing shows data:", error);
console.error('Error fetching and processing shows data:', error);
return {
shows: [],
recentlyWatched: [],
favorites: [],
favorites: []
};
}
}

View file

@ -1,22 +1,22 @@
import EleventyFetch from "@11ty/eleventy-fetch";
import EleventyFetch from '@11ty/eleventy-fetch';
const { POSTGREST_URL, POSTGREST_API_KEY } = process.env;
const fetchUpcomingShows = async () => {
try {
return await EleventyFetch(`${POSTGREST_URL}/optimized_scheduled_shows?select=*`, {
duration: "1h",
type: "json",
duration: '1h',
type: 'json',
fetchOptions: {
method: "GET",
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${POSTGREST_API_KEY}`,
},
},
'Content-Type': 'application/json',
Authorization: `Bearer ${POSTGREST_API_KEY}`
}
}
});
} catch (error) {
console.error("Error fetching upcoming shows:", error);
console.error('Error fetching upcoming shows:', error);
return [];
}
};
@ -25,5 +25,5 @@ export default async function () {
const data = await fetchUpcomingShows();
const upcomingShows = data?.[0]?.scheduled_shows;
return upcomingShows
return upcomingShows;
}