XSLT
Published on
As I planned in the 3.1 launch post, I've now implemented XSLT support in XSite. Using this tool, I've implemented some improvements to the site to restore some of the pieces that got cut to fit into XSite. This should improve accessibility, as well as making some things easier on myself.
I'm currently using two similar XSLT stylesheets, to handle the navbar and the blog index. Each of those is generated from what XSite calls a "dataset", in this case in the form of CSV files. These CSVs list the paths and titles of navbar entries and blog posts, along with the dates of the blog posts. XSite automatically converts the CSV data into XML for ease of processing with its tools, and the stylesheets then render them into <ul>
s of links. This output can then automatically be slotted into an XSlots template.
While the navbar was relatively simple, I went through a few ideas on how to structure the blog index before landing on what I think is the best approach: The blog index page itself just contains the heading and the explanation at the top of the page, and the entire section containing the entries (header and <section>
tag included) is generated by the XSLT. An XSlots template puts the two one after another in the <main>
element and manages the job of passing the dataset input to the XSLT sheet (something that, as yet, only XSlots can do).
The main advantage provided by the change to the navbar is that it can once again update to indicate which page is current. Each of the pages on the navbar now has a path
parameter, which the navbar XSLT can compare against the path
attribute of each entry to figure out which (if any) is the current page. It then adds aria-current
and <strong>
to mark it as the current page and changes the destination to #
so that navigating to the current page doesn't actually trigger a new request.
The blog index change doesn't currently provide much advantage, other than reducing how much I have to type to add blog posts to the index, but it will make it easier to take advantage of future blogging features I add to XSite; ideally, I should only have to switch the dataset from CSV to a dynamically-generated blog posts dataset to use that, with no changes to the XSLT necessary (though I'll probably want to make some changes once I have the option to, e.g., show the first paragraph as a teaser).
I do expect to continue adding features to XSite, in particular for blogging, but I think I've succeeded in creating a moderately-useful static site generator. It still isn't really ready for general use, since the documentation mostly hasn't been written yet, but I'll get around to that relatively soon (I've already partially written the XSlots documentation).
Tagged:
- Updates
- Site
- Projects
- V3.1