Compare commits
No commits in common. "main" and "joplin-data-api-wrapper" have entirely different histories.
main
...
joplin-dat
59
index.js
59
index.js
|
|
@ -1,26 +1,12 @@
|
||||||
// import variables from `.env`
|
// import variables from `.env`
|
||||||
import 'dotenv/config'
|
require('dotenv').config();
|
||||||
import { Client } from '@notionhq/client'
|
const { Client } = require('@notionhq/client');
|
||||||
import Joplin from './joplin.js'
|
|
||||||
|
|
||||||
const joplin = new Joplin(process.env.JOPLIN_TOKEN, process.env.JOPLIN_CLIPPER_PORT)
|
const notion = new Client({auth: process.env.NOTION_KEY});
|
||||||
const notion = new Client({auth: process.env.NOTION_TOKEN});
|
|
||||||
const joplinNotebookID = process.env.JOPLIN_NOTEBOOK_ID;
|
|
||||||
const notionDatabaseID = process.env.NOTION_DATABASE_ID;
|
|
||||||
|
|
||||||
|
const databaseID = process.env.NOTION_DATABASE_ID;
|
||||||
|
|
||||||
// essentially a main function
|
async function addItem(text) {
|
||||||
async function processNotes() {
|
|
||||||
const data = await joplin.getNotesFromNotebook(joplinNotebookID, ["title", "body", "created_time", "updated_time"])
|
|
||||||
for (let note of data) {
|
|
||||||
addPageToNotionDatabase(notionDatabaseID, note.title, note.body)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
processNotes()
|
|
||||||
|
|
||||||
|
|
||||||
async function addPageToNotionDatabase(databaseID, title, body) {
|
|
||||||
try {
|
try {
|
||||||
const response = await notion.pages.create({
|
const response = await notion.pages.create({
|
||||||
parent: {database_id: databaseID},
|
parent: {database_id: databaseID},
|
||||||
|
|
@ -28,40 +14,13 @@ async function addPageToNotionDatabase(databaseID, title, body) {
|
||||||
title: {
|
title: {
|
||||||
title: [
|
title: [
|
||||||
{
|
{
|
||||||
"type": "text",
|
|
||||||
"text": {
|
"text": {
|
||||||
"content": title,
|
"content": text
|
||||||
"link": null
|
}
|
||||||
},
|
}
|
||||||
"annotations": {
|
|
||||||
"bold": false,
|
|
||||||
"italic": false,
|
|
||||||
"strikethrough": false,
|
|
||||||
"underline": false,
|
|
||||||
"code": false,
|
|
||||||
"color": "default"
|
|
||||||
},
|
|
||||||
"plain_text": "Grocery List",
|
|
||||||
"href": null
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
children: [
|
|
||||||
{
|
|
||||||
object: "block",
|
|
||||||
type: "paragraph",
|
|
||||||
paragraph: {
|
|
||||||
"rich_text": [
|
|
||||||
{
|
|
||||||
"text": {
|
|
||||||
"content": body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
console.log(response);
|
console.log(response);
|
||||||
console.log("Success! Entry added.");
|
console.log("Success! Entry added.");
|
||||||
|
|
@ -70,4 +29,4 @@ async function addPageToNotionDatabase(databaseID, title, body) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// addItem("Yurts in Big Sur, California");
|
addItem("Yurts in Big Sur, California");
|
||||||
Loading…
Reference in New Issue