A simple guestbook

#note#meta#100DaysToOffload#guide

TL;DR: Click here to view the guestbook.

For a while now, I wanted to have a quick way to update the pages on my website.

GitHub has the "." hotkey, which opens a web based editor for the file you're currently viewing. This site now has this feature as well! To try it out, just hit ., and you'll be redirected to the file editor for this page.

To see how I implemented this feature, you take a look at this commit. It boils down to this snippet of code:

window.addEventListener("keypress", (e) => {
	if (e.key === ".") {
		const baseUrl = "https://github.com/garritfra/garrit.xyz/edit/main/content";
		const filePath = window.location.pathname;
		const url = `${baseUrl}${filePath}.md`;

		window.location.href = url;
	}
});

Pretty simple, huh?

Since this doesn't work on mobile devices, I also added a custom 404 page which also redirects to the editor, if the filepath ends with in /edit.

Let's have some fun and put this feature to use. I added a simple guestbook to this site, which is open to receive pull requests. I'd love to hear from you!

This is post 040 of #100DaysToOffload.


Continue Reading