Thursday, January 28, 2021

All About the Navigation

The silence was only because I was working on some tweaks on my personal domain.

I have been maintaining my 笛子 Materials set of articles for a long time. I was not happy with the type of navigation that was available---the old navigation mechanism was just a dynamically added ↑ that led from each article page back to the articles content page as linked above.

This meant that if one wanted to read through all the articles, one would have to keep heading back to the articles content page. Talk about super annoyance.

My entire personal domain is run off static pages, and so for a long time I had no good solution to this. That is, until I remembered the XMLHttpRequest object (XHR), and the ability to use DOM traversal on a document-type response object from XHR.

What the combination of techniques here meant was that I could literally make use of XHR to pull the articles content page, parse the links from the navigation tree, and then do whatever I wanted with it, which in this case was to dynamically create a simple in-order traversal navigation block (with a shortcut to the articles content page) to replace the traditional navigation block.

This was significant because I did not have to manually update each article page to set up the navigation blocks by hand. Articles were not written sequentially, and their names are randomly generated, which made manual setting up and updating of the ``previous article'' and ``next article'' links a pain.

The downside is that non-JavaScript enabled browsers do not have that luxury. But it's still alright since the fallback still provides a long-winded but workable manner of navigation.

That was a fun bit of exercise and functionality to add to my personal domain.

One other thing that I did was to redo how I was generating Sitemaps. Specifically, I implemented a new tool that would generate the associated sitemap.xml file complete with last modified date/time to be uploaded into the host. Previously, I was just doing some lousy shell script that listed all files that were hosted, but it was not the right thing to do for the purpose of a Sitemap. In addition, the old Sitemap that I made was only for Google, but this Sitemap that I now generate applies to all who conform to the protocol too. This may mean that my personal domain may get better indexing from the other search providers.

It is definitely a minor thing, but is one of those hidden quality of life things that should prove to be useful in the long run.

I think that's about all the update I would like to put up today. Till the next time.

No comments: