-
-
Save danott/e0ff791aa8a2fb98b625037efea8c252 to your computer and use it in GitHub Desktop.
The source code for my bookmarklet
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
var date = new Date() | |
date.setHours(date.getHours() - date.getTimezoneOffset() / 60) | |
date = date.toISOString().split("T").at(0) | |
var title = window.prompt("What's a good starter title?", document.title) | |
var slug = window.prompt("what's a good slug?", title.toLowerCase().replace(/\s+/g, "-")) | |
var filename = "content/posts/" + date + "-" + slug +".md" | |
var value = "#bookmark\n\n# [" + title + "](" + window.location.toString() + ")\n\n" | |
var quote = window.getSelection().toString() | |
if (quote) value += "> " + quote + "\n\n" | |
var url = new URL("https://github.com/danott/www.danott.co/new/main") | |
url.searchParams.append("filename", filename) | |
url.searchParams.append("value", value) | |
window.open(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment