Skip to content

Instantly share code, notes, and snippets.

@briankung
Last active May 24, 2018 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briankung/4c6b2201e997f115061c575352f77830 to your computer and use it in GitHub Desktop.
Save briankung/4c6b2201e997f115061c575352f77830 to your computer and use it in GitHub Desktop.
[RFC] GitHub Gists are officially the backend of my blog

Well! I'm officially pretty happy with the fruits of my labor. It's not the prettiest, aesthetically or in terms of code quality, but hey, it does exactly what I want it to. Now I can use GitHub Gists as the backend to my blog - at least until I hit 3000 gists. I count that among problems I probably won't have to deal with, including:

  1. Getting slashdotted / hackernewsed
  2. GitHub changing their access model for public gists
  3. GitHub rate limiting me
  4. Having more blog posts than I know what to do with
  5. Having more viewers or subscribers than I know what to do with

I'll deal with those problems as they come. In the meantime, a quick rundown of what changed since the last post:

  1. Uses more semantic html: Basically each gist is an <article> and each file in the gist is a <section> in that <article>
  2. Faux permalinks: The entire blog will load every time, so I just had to figure out a way to focus in on the article that was actually linked. To that end, I used scrollIntoView. At first, I used focus, but it was giving me issues - I suspect it had to do with dynamically adding the elements, but it still didn't work even after waiting (or doing it manually), so I just found a method that did work.

In a week, when I can't understand my own code, I might rewrite it into something more declarative, which would be neat. Something like:

const preHTML = {
html: {
body: {
'article#and-its-id': {
section: {
p: 'blah blah blah'
}
}
}
}
}
const builder = new HTMLBuilder(preHTML)
builder.toHTML() // <html><body><article id="and-its-id">...

Stuff like that probably exists already, but it might be fun to write, myself. That said, I'd love to hear about alternatives if you know of any.

Frankly, if I were to take it seriously, I should probably write it in something well established, like Vue, which I already know.

...but where's the fun in that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment