Tip: Instantly Edit Your Eleventy Site on Github

dz4k

Deniz Akşimşek

Posted on September 17, 2020

Tip: Instantly Edit Your Eleventy Site on Github

You’re looking at the blog post you made yesterday, when suddenly a typo catches your eye. What is the fastest way to fix it? (Skip to code).

Note: This tip assumes you use GitHub. It could likely be adapted easily for other Git providers.

Add the following to your base layout (note the {{ }} and replace <username>/<repo> with the repo for the site):

<script>
addEventListener('keyup', e => {
  if (e.shiftKey === true) {
    switch (e.keyCode) {
    case 69: // E
      window.location = 'https://github.com/<username>/<repo>/edit/master/{{page.inputPath}}'
      break 
    }
  } 
})
</script>
Enter fullscreen mode Exit fullscreen mode

When you press Shift+E, the GitHub editor will open to the current page! The switch statement is there because I used to have a few more hotkeys.

💖 💪 🙅 🚩
dz4k
Deniz Akşimşek

Posted on September 17, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related