fixed some things. and did some UI changes
This commit is contained in:
18
js/post/download.js
Normal file
18
js/post/download.js
Normal file
@@ -0,0 +1,18 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// current page URL
|
||||
let url = window.location.href;
|
||||
|
||||
// replace `/html/` with `/markdown/`
|
||||
url = url.replace("/html/", "/markdown/");
|
||||
|
||||
// replace `.html` with `.md`
|
||||
url = url.replace(/\.html$/, ".md");
|
||||
|
||||
// assign to <a>
|
||||
const a = document.getElementById("download-md");
|
||||
a.href = url;
|
||||
|
||||
// suggest filename
|
||||
const filename = url.split("/").pop(); // e.g. markdowntest.md
|
||||
a.download = filename;
|
||||
});
|
||||
Reference in New Issue
Block a user