chore: filters + cleanup
This commit is contained in:
parent
360111c784
commit
515da740ba
5 changed files with 35 additions and 28 deletions
|
@ -164,9 +164,9 @@ export const processContent = (collection) => {
|
||||||
export const albumReleasesCalendar = (collection) => {
|
export const albumReleasesCalendar = (collection) => {
|
||||||
const collectionData = collection.getAll()[0]
|
const collectionData = collection.getAll()[0]
|
||||||
const { data } = collectionData
|
const { data } = collectionData
|
||||||
const { albumReleases } = data
|
const { albumReleases: { all } } = data;
|
||||||
if (!albumReleases || albumReleases.length === 0) return ''
|
if (!all || all.length === 0) return ''
|
||||||
const events = albumReleases.map(album => {
|
const events = all.map(album => {
|
||||||
const date = DateTime.fromFormat(album.date, 'MMMM d, yyyy')
|
const date = DateTime.fromFormat(album.date, 'MMMM d, yyyy')
|
||||||
if (!date.isValid) return null
|
if (!date.isValid) return null
|
||||||
|
|
||||||
|
@ -183,6 +183,7 @@ export const albumReleasesCalendar = (collection) => {
|
||||||
}).filter(event => event !== null)
|
}).filter(event => event !== null)
|
||||||
|
|
||||||
const { error, value } = ics.createEvents(events)
|
const { error, value } = ics.createEvents(events)
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error creating events: ', error)
|
console.error('Error creating events: ', error)
|
||||||
events.forEach((event, index) => {
|
events.forEach((event, index) => {
|
||||||
|
|
26
package-lock.json
generated
26
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "24.4.1",
|
"version": "24.4.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "24.4.1",
|
"version": "24.4.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cdransf/api-text": "^1.5.0",
|
"@cdransf/api-text": "^1.5.0",
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
"@11ty/eleventy": "v3.0.0-beta.1",
|
"@11ty/eleventy": "v3.0.0-beta.1",
|
||||||
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
|
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
|
||||||
"@cdransf/eleventy-plugin-tabler-icons": "^1.12.0",
|
"@cdransf/eleventy-plugin-tabler-icons": "^1.12.0",
|
||||||
"@supabase/supabase-js": "^2.45.2",
|
"@supabase/supabase-js": "^2.45.3",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"cssnano": "^7.0.5",
|
"cssnano": "^7.0.5",
|
||||||
"dotenv-flow": "^4.1.0",
|
"dotenv-flow": "^4.1.0",
|
||||||
|
@ -565,9 +565,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@supabase/auth-js": {
|
"node_modules/@supabase/auth-js": {
|
||||||
"version": "2.64.4",
|
"version": "2.65.0",
|
||||||
"resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.64.4.tgz",
|
"resolved": "https://registry.npmjs.org/@supabase/auth-js/-/auth-js-2.65.0.tgz",
|
||||||
"integrity": "sha512-9ITagy4WP4FLl+mke1rchapOH0RQpf++DI+WSG2sO1OFOZ0rW3cwAM0nCrMOxu+Zw4vJ4zObc08uvQrXx590Tg==",
|
"integrity": "sha512-+wboHfZufAE2Y612OsKeVP4rVOeGZzzMLD/Ac3HrTQkkY4qXNjI6Af9gtmxwccE5nFvTiF114FEbIQ1hRq5uUw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -631,13 +631,13 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@supabase/supabase-js": {
|
"node_modules/@supabase/supabase-js": {
|
||||||
"version": "2.45.2",
|
"version": "2.45.3",
|
||||||
"resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.45.2.tgz",
|
"resolved": "https://registry.npmjs.org/@supabase/supabase-js/-/supabase-js-2.45.3.tgz",
|
||||||
"integrity": "sha512-kJKY3ISFusVKQWCP8Kqo20Ebxy2WLp6Ry/Suco0aQsPXH7bvn7clswsdhcfcH/5Tr0MYz/jcCjF0n/27SetiCw==",
|
"integrity": "sha512-4wAux6cuVMrdH/qUjKn6p3p3L9AtAO3Une6ojIrtpCj1RaXKVoyIATiacSRAI+pKff6XZBVCGC29v+z4Jo/uSw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@supabase/auth-js": "2.64.4",
|
"@supabase/auth-js": "2.65.0",
|
||||||
"@supabase/functions-js": "2.4.1",
|
"@supabase/functions-js": "2.4.1",
|
||||||
"@supabase/node-fetch": "2.6.15",
|
"@supabase/node-fetch": "2.6.15",
|
||||||
"@supabase/postgrest-js": "1.15.8",
|
"@supabase/postgrest-js": "1.15.8",
|
||||||
|
@ -1066,9 +1066,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/caniuse-lite": {
|
"node_modules/caniuse-lite": {
|
||||||
"version": "1.0.30001653",
|
"version": "1.0.30001655",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001653.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001655.tgz",
|
||||||
"integrity": "sha512-XGWQVB8wFQ2+9NZwZ10GxTYC5hk0Fa+q8cSkr0tgvMhYhMHP/QC+WTgrePMDBWiWc/pV+1ik82Al20XOK25Gcw==",
|
"integrity": "sha512-jRGVy3iSGO5Uutn2owlb5gR6qsGngTw9ZTb4ali9f3glshcNmJ2noam4Mo9zia5P9Dk3jNNydy7vQjuE5dQmfg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "24.4.1",
|
"version": "24.4.2",
|
||||||
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -35,7 +35,7 @@
|
||||||
"@11ty/eleventy": "v3.0.0-beta.1",
|
"@11ty/eleventy": "v3.0.0-beta.1",
|
||||||
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
|
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
|
||||||
"@cdransf/eleventy-plugin-tabler-icons": "^1.12.0",
|
"@cdransf/eleventy-plugin-tabler-icons": "^1.12.0",
|
||||||
"@supabase/supabase-js": "^2.45.2",
|
"@supabase/supabase-js": "^2.45.3",
|
||||||
"autoprefixer": "^10.4.20",
|
"autoprefixer": "^10.4.20",
|
||||||
"cssnano": "^7.0.5",
|
"cssnano": "^7.0.5",
|
||||||
"dotenv-flow": "^4.1.0",
|
"dotenv-flow": "^4.1.0",
|
||||||
|
|
|
@ -6,7 +6,7 @@ const SUPABASE_KEY = process.env.SUPABASE_KEY
|
||||||
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
|
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
|
||||||
|
|
||||||
const fetchAlbumReleases = async () => {
|
const fetchAlbumReleases = async () => {
|
||||||
const today = DateTime.utc().toISO()
|
const today = DateTime.utc().startOf('day')
|
||||||
const { data, error } = await supabase
|
const { data, error } = await supabase
|
||||||
.from('optimized_album_releases')
|
.from('optimized_album_releases')
|
||||||
.select(`
|
.select(`
|
||||||
|
@ -17,24 +17,30 @@ const fetchAlbumReleases = async () => {
|
||||||
art,
|
art,
|
||||||
artist_name
|
artist_name
|
||||||
`)
|
`)
|
||||||
.gt('release_date', today)
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('Error fetching data:', error)
|
console.error('Error fetching data:', error)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
const all = data.map(album => {
|
||||||
.filter(album => !album['total_plays'] || album['total_plays'] <= 0)
|
const releaseDate = DateTime.fromISO(album['release_date']).toUTC().startOf('day')
|
||||||
.map(album => ({
|
|
||||||
|
return {
|
||||||
artist: album['artist_name'],
|
artist: album['artist_name'],
|
||||||
title: album['name'],
|
title: album['name'],
|
||||||
date: DateTime.fromISO(album['release_date']).toLocaleString(DateTime.DATE_FULL),
|
date: releaseDate.toLocaleString(DateTime.DATE_FULL),
|
||||||
url: album['release_link'],
|
url: album['release_link'],
|
||||||
image: album['art'] ? `/${album['art']}` : '',
|
image: album['art'] ? `/${album['art']}` : '',
|
||||||
type: 'album-release'
|
total_plays: album['total_plays'],
|
||||||
}))
|
release_date: releaseDate,
|
||||||
.sort((a, b) => a['timestamp'] - b['timestamp'])
|
type: 'album-release',
|
||||||
|
timestamp: releaseDate.toSeconds(),
|
||||||
|
}
|
||||||
|
}).sort((a, b) => a['timestamp'] - b['timestamp'])
|
||||||
|
const upcoming = all.filter(album => (!album['total_plays'] || album['total_plays'] <= 0) && album['release_date'] > today);
|
||||||
|
|
||||||
|
return { all, upcoming }
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
|
|
|
@ -51,5 +51,5 @@ schema: music-index
|
||||||
{% tablericon "calendar-time" "Anticipated albums" %}
|
{% tablericon "calendar-time" "Anticipated albums" %}
|
||||||
Anticipated albums
|
Anticipated albums
|
||||||
</h3>
|
</h3>
|
||||||
{% render "partials/media/grid.liquid", data:albumReleases, shape: "square", count: 8 %}
|
{% render "partials/media/grid.liquid", data:albumReleases.upcoming, shape: "square", count: 8 %}
|
||||||
{% endif %}
|
{% endif %}
|
Reference in a new issue