Avatar

stelabouras

The Unity Library

Sunday, March 15, 2020

...or how to write a simple static website generator in a day.

Ten days ago I launched a simple project called 'The Unity Library'.

The Unity Library is a small, curated collection of Unity related tutorials, posts and tips that I kept for personal reference, which I decided to make public as a means of giving back to this amazing community.

Here's the Twitter thread of the announcement:

The response was quite overwhelming and definitely disproportionate to the amount of time I spent building it! 🥰

The whole idea started when I noticed that a collection of Unity-related links I was maintaing, was growing significantly in number on my Linkpack folder and I needed a separate searchable interface which I could consult often without having to go through my files. So I began grouping those files into folders and ended up creating a simple parser script to generate the library structure.

I reused some simple logic already implemented in Python on the server-side of Linkpack, so that I could extract the necessary information from the file structure into a JSON format. The script was aptly named the ..."Librarian", as it was tasked with traversing the whole folder, parsing the files, extracting the links, checking the Open Graph tags of the website, storing the url in the Wayback Machine, and finally storing the whole library JSON structure into a separate file.

After that, I created a simple generator script that was responsible for creating the whole static website from that JSON script, by generating the proper folder structure, building the HTML files, copying the static CSS and JS I have coded to style the pages correctly and getting the whole JSON structure loaded in Javascript so that the whole website is searchable.

For hosting the project, I picked the trusted Netlify service, the same service this very blog is hosted at!

Overall 'The Unity Library' was a rather fun little project and something that I keep improving those days whenever I have a chance.

P.S. I am considering of open-sourcing the whole project (although the underlying logic isn't something groundbreaking), once I get to improve the code past my impostor syndrome thresholds. 😉