MS

Hello, I’m Michael Sliwinski, founder of Nozbe - to-do app for business owners and their teams. I write essays, books, work on projects and I podcast for you using #iPadOnly in #NoOffice as I believe that work is not a place you go to, it’s a thing you do.

Coding is one of my favorite hobbies. It’s my happy place.

⌨️Blogging,😎Life

One of my best personal decisions of the pandemic-driven 2020 was to finally migrate my old blog from Sliwinski.com to this. To Michael.team. And not only because I have a new, shorter domain, but mostly because it’s a different technology stack and I can completely control it. I wrote about the transition here. As in Nozbe I hire brilliant programmers, I don’t code the app anymore. But I still like using programming languages to build something out of nothing and for this purpose, this blog is my place to do that.Last weekend I decided to get back to coding and built some long-overdue features like “next post”, “previous post” and “related posts”. It was so much fun! Read on, if you’re a programming geek like me:

Coding is one of my favorite hobbies. It’s my happy place.

Embracing the limitations of GitHub Pages and Jekyll

First off, my new blog is hosted on GitHub Pages and I didn’t want to change that. I didn’t want to have to manage additional server infrastructure. This means I have to embrace the only blogging engine they offer, which is Jekyll and only few of the built-in plugins of that platform.

Even with embracing these constraints I’m able to build a pretty robust blog with three language versions: English (this), Polish and Spanish. However, this also means that to build additional features on top of it I sometimes need to resort to hacking the system. This time I decided to sprinkle some lightweight JavaScript on top of the blog to build two additional features: previous/next post navigation and related posts section.

Including lightweight JavaScript in every blog post

I’ve included a simple post.js script in the layout of each blog post on my blog (including this one!) and what it does is this:

1) It runs once asynchronously in the background to check the list of blog posts in JSON and finds out which blog post we’re on and which are the previous and next ones. In the same time it sends another asynchronous request to check the same file for three most recent related blog posts (the ones with the same tag) and fetches them as well.

2) Once fetched, it displays the previous / next blog posts below the blog entry as well as the related section with the up to three related blog posts.

3) Because the blog post loads first, the person visiting my site can be reading it while the JavaScript fetches all the relevant information in the background and adds it below the post. Speed all around!

It works across all the languages I support, above I pasted a screenshot from the English “vaccine” article and below you can see a screenshot from the Polish „Piąteczek” article about our Mighty Fridays.

Coding is one of my favorite hobbies. It’s my happy place. 2

Modern JavaScript is fun!

When I wrote the first version of Nozbe I had to choose a JavaScript framework for it. The first one I used was the PrototypeJS. Later we switched over to jQuery just to be able to write the same code and support many browsers.

These days I can write pure JavaScript. No extra framework. No additional hassle. I learn the latest language reference at Javascript.info and build my playgrounds on JSFiddle while coding it directly on my new 13” iPad Pro.

And if someone who visits my site is on an old computer and doesn’t support the latest JavaScript, no problem - the site will load just fine and ignore the code. After all, on my blog JavaScript is not required and my blog posts are perfectly readable without it. JavaScript is an additional bonus feature.

Apart from enhancing my blog, I like learning JavaScript to build additional useful things, like my Dice project and YouTube player. And I have more JavaScript enhancements planned for the future.

Programming is my happy place!

Day to day I’m a CEO and a leader of a software company and a writer. Programming from time to time gives me these additional mental challenges which are fun but aren’t required to meet any strategic goals.

Programming brings me joy.

Monday, November 15, 2021 /postjs/