This week our task was to refactor our SSG's. The main point of refactoring is to simplify to make our code more efficient to use and read. I had some ideas of what to fix but i still needed to look and see what I could fix and how I would fix it.
What did I Refactor
The biggest and most impact-full change i made was a adding two new functions one for searching and one for replacing. multiple times i would just copy and paste the code and just add a different string for the searching and replacing parts but this time i put them into two functions and simplified my code. In the long run this will be much easier to read and I can re use this code to implement the other features of markdown like adding in link support.
The second change i made was simplifying my HTML creation i added a variable that stored the header file of the HTML doc then i would build off of that variable.
My last change built of my previous changes by creating the title of the file in the first part of the function instead of having two identical title creation variables.
Top comments (0)