Skip to content

Instantly share code, notes, and snippets.

Created May 19, 2021 20:01
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Automate new Short Links
// Menu: New Short Link
// Modified version of'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