--- template: url: site-changes title: Site changes subtitle: New stuff at the {back,front}end date: 2020-05-27 --- The past couple of days, I've spent a fair amount of time tweaking this site. My site's build process involves [vite](https://github.com/icyphox/vite) and a bunch of [scripts](https://github.com/icyphox/site/tree/master/bin). These scripts are executed via vite's pre- and post-build actions. The big changes that were made were performance improvements in the `update_index.py` script, and the addition of `openring.py`, which you can see at the very bottom of this post! ## speeding up index page generation The old script---the one that featured in [Hacky scripts](/blog/hacky-scripts)---was absolutely ridiculous, and not to mention _super_ slow. Here's what it did: - got the most recent file (latest post) by sorting all posts by `mtime`. - parsed the markdown frontmatter and created a markdown table entry like: ```python line = f"| [{meta['title']}]({url}) | `{meta['date']}` |" ``` - updated the markdown table (in `_index.md`) by in-place editing the markdown, with the line created earlier---for the latest post. - finally, I'd have to _rebuild_ the entire site since this markdown hackery would happen at the very end of the build, i.e, didn't actually get rendered itself. That...probably didn't make much sense to you, did it? Don't bother. I don't know what I was thinking when I wrote that mess. So with how it _was_ done aside, here's how it's done now: - the metadata for all posts are nicely fetched and sorted using `python-frontmatter`. - the metadata list is fed into Jinja for use in templating, and is rendered very nicely using a simple `for` expression: ``` {% for p in posts %}