Created
May 19, 2021 20:01
-
-
Save higby/1c5c226bd6ad5311fd13166fdbeee1eb to your computer and use it in GitHub Desktop.
Automate new Short Links
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
// Menu: New Short Link | |
// Modified version of https://github.com/dealingwith's 'new-post.js' | |
let worked = "Short link added" | |
let link = await arg('Link to?') | |
let slug = await arg('Slug?') | |
let file_slug = slug.toLowerCase().replaceAll(' ', '-') | |
let redirect_path = '(( path to redirects folder))' | |
let file_path = redirect_path + file_slug + '.md' | |
let file_contents = `--- | |
redirect_to: ${link} | |
--- | |
` | |
await writeFile(file_path, file_contents) | |
terminal('cd ((path to repository folder));git add .;git commit -m "New short URL";git push origin main --force') | |
copy('((short-url url))'+slug) | |
notify('Short URL created @ ((short-url url))'+slug+'!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment