Hi everyone,
This week I worked with Alex to add a new feature to our SSGs. This new feature was the ability to use a JSON config file to pass in options instead of typing in the options manually in the command line. I worked on Alex's repo.
The code wasn't too difficult to write. I added new options -c
and --config
which would use a JSON config file to get all the options needed when generating the HTML file. For example, the contents of the config file could look like this:
{
"input": "./site",
"output": "./build",
"stylesheet": "https://cdn.jsdelivr.net/npm/water.css@2/out/water.css",
"lang": "fr"
}
The code process I did was to first check if the config file exists and is JSON formatted, then read from the file and put the contents into an object, and finally use the properties from the object to get all the options. The biggest issue I had was making sure not to duplicate code, so I had to change a few things in the code before I could add my changes.
The biggest thing I learned from this process was using a couple of new features from Git. I used the Draft Pull Request for the first time and found how useful that feature is. It's cool how you can continually add commits to the PR until you believe it is ready for review. I also learned how to use a git remote, which is used to work with a different repo that you didn't clone. I used this feature to get my partner's work form his branch onto my computer so that I could review and test his code.
Luckily, the instructions were pretty clear, so I had no problems with these new Git features, but I still feel I need practice with them. I'll continue to use these features throughout my programming career.
Top comments (0)