Skip to content

Commit

Permalink
Save the source of my bookmarklet
Browse files Browse the repository at this point in the history
  • Loading branch information
danott committed Jan 15, 2024
1 parent 5900107 commit 2f58c52
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions site/javascripts/bookmarklets/post.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* @format
*
* Make it usable at https://bookmarklets.org/maker/
*/

var date = new Date();
date.setHours(date.getHours() - date.getTimezoneOffset() / 60);

var year = date.getFullYear();
var dateString = date.toISOString().split("T").at(0);
var title = window.prompt("Title", document.title);
var slug = window.prompt("Slug", title.toLowerCase().replace(/\s+/g, "-"));

var filename = "site/" + year + "/" + slug + ".md";
var value = "<template data-parse>" + dateString + "</template>\n\n# " + title;

var url = new URL("https://github.com/danott/website/new/main");
url.searchParams.append("filename", filename);
url.searchParams.append("value", value);

window.open(url);

0 comments on commit 2f58c52

Please sign in to comment.