Skip to content

Instantly share code, notes, and snippets.

@tschoffelen
Created March 5, 2021 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tschoffelen/291d92149823b78f6d052543f603035c to your computer and use it in GitHub Desktop.
Save tschoffelen/291d92149823b78f6d052543f603035c to your computer and use it in GitHub Desktop.
Little tool I built for myself to export roam notes.
window.exportRoamNote = async () => {
const noteId = Math.round(Math.random()*10000) + '-note.md';
const body = $('.roam-body .roam-app .roam-main .roam-article')[0].innerHTML;
const boxUrl = 'https://mrm5dm6of9.execute-api.eu-west-1.amazonaws.com/'
+ 'production/box/get-url?filename='+noteId+'&'
+ 'contentType=text%2Fplain';
const res = await fetch(boxUrl, {method: 'GET' });
const {key, url} = await res.json();
await fetch(url, {
method: "PUT",
body,
headers: {
'Content-Type': 'text/plain',
'ContentEncoding': 'utf-8'
}
})
const noteUrl = `https://schof.co/notes/${key.replace('-note.md', '').replace('f/','').replace('/','-')}`;
console.log(noteUrl);
window.open(noteUrl);
}
setTimeout(() => {
$('#export-share').length || $('.rm-topbar').append('<span id="export-share" onclick="window.exportRoamNote()">⬆️</span>')
}, 2500);
@tschoffelen
Copy link
Author

Added using the {{[[roam/js]]}} tag, with a nested code block:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment