const listItems = album.tracks.map((item) => ({
numbered_list_item: {
rich_text: [
{
text: {
content: item,
},
},
],
},
}));
function getISODate(dateString) {
return new Date(dateString).toISOString();
}
const page = {
parent: {
data_source_id: data_source_id,
},
properties: {
Name: {
title: [
{
text: {
content: album.name,
},
},
],
},
Artist: {
rich_text: [
{
text: {
content: album.artist,
},
},
],
},
Released: {
date: {
start: getISODate(album.release_date),
},
},
},
children: [
{
heading_1: {
rich_text: [
{
text: {
content: "Tracklist",
},
},
],
},
},
...listItems,
{
heading_1: {
rich_text: [
{
text: {
content: "Album Art",
},
},
],
},
},
{
image: {
external: {
url: album.cover,
},
},
},
],
};
const response = notion.pages.create(page);