Post Current URL to Tana with Metadata

Open post-url-to-tana in Script Kit

// Name: Post URL with Metadata to Tana
import "@johnlindquist/kit"
let og = await npm("opengraph-io")
// You'll need to sign-up for https://www.opengraph.io/
// Create a free account and grab an API key from: https://dashboard.opengraph.io/apis/Opengraphio
// Paste the token when prompted for OPENGRAPH_API_ID_TOKEN
let openGraph = og({
appId: await env("OPENGRAPH_API_ID_TOKEN", {
hint: `Grab a token from [here](https://dashboard.opengraph.io/apis/Opengraphio)`,
}),
cacheOk: true, // If a cached result is available, use it for quickness
useProxy: false, // Proxies help avoid being blocked and can bypass capchas
maxCacheAge: 432000000, // The maximum cache age to accept
acceptLang: "en-US,en;q=0.9", // Language to present to the site.
fullRender: false, // This will cause JS to execute when rendering to deal with JS dependant sites
})
let url = await getActiveTab()
// on windows, remove above and use:
// let url = await arg("Paste URL here")
let result = await openGraph.getSiteInfo(url)
debugger
if (result.openGraph.error) {
await editor(result.openGraph.error)
} else {
let { title, site_name, description } = result.openGraph
// In the future, Tana will support more than just raw text
// For now, only text is supported.
// This gives you a chance to tweak the Title/Description before posting:
let note = await template(
`
${title} - ${site_name}
- ${url}
- ${description}
`.trim()
)
let TANA_URL =
"https://europe-west1-tagr-prod.cloudfunctions.net"
// Select a node in Tana, hit cmd+K from mac, ctrl+K for windows, search for "API" to generate a token
// Paste the token when prompted
let TANA_TOKEN_TODOS = await env("TANA_TOKEN_TODOS_TWO")
await hide()
// await copy(note.trim()) if you prefer to copy/paste you can use this instead
await get(`${TANA_URL}/addToNode`, {
headers: {
authorization: `Bearer ${TANA_TOKEN_TODOS}`,
},
params: {
note: note.trim(),
},
})
}
debugger