Created
April 20, 2023 08:03
-
-
Save alanalvestech/7a135c221945390dad30ae54a35b080d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await doc.useServiceAccountAuth({ | |
client_email: process.env.GOOGLE_SERVICE_ACCOUNT_EMAIL || "", | |
private_key: process.env.GOOGLE_PRIVATE_KEY || "".replace(/\\n/g, "\n"), | |
}); | |
// Carrega as informações da planilha | |
await doc.loadInfo(); | |
// Seleciona a primeira guia da planilha | |
const sheet = doc.sheetsByTitle['tools']; | |
sheet.getRows().then(rows => { | |
rows.map(async row => { | |
let linkObject = new URL(row.link); | |
let teste = await notion.pages.create({ | |
parent: { | |
database_id: "", | |
}, | |
properties: { | |
Name: { | |
title: [ | |
{ | |
text: { | |
content: row.name, | |
}, | |
}, | |
], | |
}, | |
Link: { | |
rich_text: [ | |
{ | |
text: { | |
content: linkObject.origin, | |
}, | |
}, | |
], | |
}, | |
Price: { | |
select: { name: row.price.replace(/^\w/, c => c.toUpperCase()) }, | |
} | |
}, | |
}); | |
await notion.blocks.children.append({ | |
block_id: teste.id, | |
children: [ | |
{ | |
"heading_1": { | |
"rich_text": [ | |
{ | |
"text": { | |
"content": "Resumo" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"paragraph": { | |
"rich_text": [ | |
{ | |
"text": { | |
"content": row.summary | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"heading_1": { | |
"rich_text": [ | |
{ | |
"text": { | |
"content": "Descrição" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"paragraph": { | |
"rich_text": [ | |
{ | |
"text": { | |
"content": row.description.replace(/(<([^>]+)>)/gi, ""), | |
} | |
} | |
] | |
} | |
} | |
], | |
}); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment