Created
September 26, 2020 03:43
-
-
Save p-baleine/1790ea8354c79b592aca00273ac2ffcf to your computer and use it in GitHub Desktop.
org-roam capture script
This file contains 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
javascript:(function() { | |
try { | |
const maxTitleLength = 52; | |
const title = document.title.length > maxTitleLength ? | |
`${document.title.slice(0, maxTitleLength)}...` : document.title; | |
const href = document.location.href; | |
const hashFragment = document.location.hash ? | |
` | ${document.location.hash}` : ''; | |
const text = `${title}${hashFragment}`; | |
const linkText = `[[${href}][${text}]]`; | |
navigator.clipboard.writeText(linkText); | |
} catch (e) { | |
alert(`Failed to clip org-roam link, ${e}`); | |
} | |
}()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment