Skip to content

Instantly share code, notes, and snippets.

@alancriaxyz
Created April 20, 2023 08:03
Show Gist options
  • Save alancriaxyz/7a135c221945390dad30ae54a35b080d to your computer and use it in GitHub Desktop.
Save alancriaxyz/7a135c221945390dad30ae54a35b080d to your computer and use it in GitHub Desktop.
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