chore: normalize formatting
This commit is contained in:
parent
01ed2ac3b3
commit
2f6cfbe7ae
61 changed files with 921 additions and 743 deletions
|
@ -1,37 +1,45 @@
|
|||
import { DateTime } from 'luxon'
|
||||
import ics from 'ics'
|
||||
import { DateTime } from "luxon";
|
||||
import ics from "ics";
|
||||
|
||||
export const albumReleasesCalendar = (collection) => {
|
||||
const collectionData = collection.getAll()[0]
|
||||
const { data } = collectionData
|
||||
const { albumReleases: { all } } = data
|
||||
if (!all || all.length === 0) return ''
|
||||
const collectionData = collection.getAll()[0];
|
||||
const { data } = collectionData;
|
||||
const {
|
||||
albumReleases: { all },
|
||||
} = data;
|
||||
if (!all || all.length === 0) return "";
|
||||
|
||||
const events = all.map(album => {
|
||||
const date = DateTime.fromISO(album['release_date'])
|
||||
if (!date.isValid) return null
|
||||
const events = all
|
||||
.map((album) => {
|
||||
const date = DateTime.fromISO(album["release_date"]);
|
||||
if (!date.isValid) return null;
|
||||
|
||||
return {
|
||||
start: [date.year, date.month, date.day],
|
||||
startInputType: 'local',
|
||||
startOutputType: 'local',
|
||||
title: `Release: ${album['artist']['name']} - ${album['title']}`,
|
||||
description: `Check out this new album release: ${album['url']}. Read more about ${album['artist']['name']} at https://coryd.dev${album['artist']['url']}`,
|
||||
url: album['url'],
|
||||
uid: `${date.toFormat('yyyyMMdd')}-${album['artist']['name']}-${album['title']}@coryd.dev`,
|
||||
timestamp: DateTime.now().toUTC().toFormat("yyyyMMdd'T'HHmmss'Z'")
|
||||
}
|
||||
}).filter(event => event !== null)
|
||||
return {
|
||||
start: [date.year, date.month, date.day],
|
||||
startInputType: "local",
|
||||
startOutputType: "local",
|
||||
title: `Release: ${album["artist"]["name"]} - ${album["title"]}`,
|
||||
description: `Check out this new album release: ${album["url"]}. Read more about ${album["artist"]["name"]} at https://coryd.dev${album["artist"]["url"]}`,
|
||||
url: album["url"],
|
||||
uid: `${date.toFormat("yyyyMMdd")}-${album["artist"]["name"]}-${
|
||||
album["title"]
|
||||
}@coryd.dev`,
|
||||
timestamp: DateTime.now().toUTC().toFormat("yyyyMMdd'T'HHmmss'Z'"),
|
||||
};
|
||||
})
|
||||
.filter((event) => event !== null);
|
||||
|
||||
const { error, value } = ics.createEvents(events, { calName: 'Album releases calendar / coryd.dev' })
|
||||
const { error, value } = ics.createEvents(events, {
|
||||
calName: "Album releases calendar / coryd.dev",
|
||||
});
|
||||
|
||||
if (error) {
|
||||
console.error('Error creating events: ', error)
|
||||
console.error("Error creating events: ", error);
|
||||
events.forEach((event, index) => {
|
||||
console.error(`Event ${index}:`, event)
|
||||
})
|
||||
return ''
|
||||
console.error(`Event ${index}:`, event);
|
||||
});
|
||||
return "";
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
|
Reference in a new issue