This week, I was tasked with adding another feature to my static site generator rost_gen based on Docusaurus features. Docusaurus is a great static site generator that has a lot of features. It provides a starting template, and even a command to deploy to github pages.
After playing around with Docusaurus for a bit and some deliberation, I decided it would be best to add support for parsing links to other pages (internal and external). If implemented properly, it would allow me to easily add additional inline markdown features such as bold, italic, etc. I broke down the feature into several parts and created issues for them:
I estimated that I would be able to implement all of these this week. It did not take me long to figure out the logic for these features as it just involves checking each line for the correct markdown. So, I created branches as needed and starting implementing them.
Line parsing was easy and I was able to finish it fairly quickly (PR).
However, since I do not have much experience in rust, it took me longer than I expected to code the logic for parsing links (PR). I had to learn about rust basics such as borrowing and mutable variables that I had not encountered in any other languages.
Thus, as of writing this, I have only finished implementing the first two parts of the feature. That is, currently, any line with the following markdown will be converted into a link:
This is a [link](www.example.com) to www.example.com
The above markdown will result in the following html:
This is a <a href="www.example.com">link</a> to www.example.com.
Next step would be to extend this markdown support for image links, which just adds an exclamation mark at the beginning:
![Image alt text](Image URL)
This would create an image tag with the specified alt text and URL.
Eventually, I also plan to implement the fourth part of the feature, which would be head metadata support. This would be something like the following markdown at the beginning of the markdown file:
---
title: "Page title"
stylesheet: _(Link to a stylesheet)_
stylesheet: _(Link to another stylesheet)_
script: _(Link to a script file)_
---
This would add the appropriate data/links to the head tag of the generated html. However, I have not yet decided if I want to use this syntax for multiple stylesheets.
Top comments (0)