DEV Community

Vivian
Vivian

Posted on

OSD600 - Contributing To Other Repo

1. Lab2 requirement

In this lab, I am asked to pick another student SSG repo and add initial support for Markdown by

  • modifying the file handling so it will support both .txt and .md files.
  • implementing at least one of the Markdown syntax features (Italics, Bold, Heading1, Heading2, or a Link).

I decided to work on Minh Quan's repo in this lab and implemented Heading1, Heading2 and Links syntax features for his SSG.

2. Process of contribution

Before forking Minh Quan's repo, I created an Issue to announce him that I'd like to work on his repo and tell him what I'm planning to do.

After that, I read through his source code to get his logic and identify reusable code. As a result, I can write the code closely to his style and change as little as possible in the existing code.

Below are two modifications I have made to add the Markdown support to his SSG.

  • Modifying the file handling

In this part, the logic for filtering out .txt and .md file(s) is the same so I just changed a bit in the inputProccess.js file by allowing ".md" to also pass the filter() function. By doing so, the SSG accepts ".md" file as a validate input now and passes it(after using join() to get correct path) into generateHTMLFile(arg1, arg2) function as the first argument.

Input is a folder
image

Input is a file
image

  • Implementing Heading1, Heading2 and Links syntax features for the SSG

In the generateHTMLFile(arg1, arg2) function, the file once more time is checked for its extension. If the extension is .md, this snip code will be executed

image

3. Create a Pull Request

The code works perfectly in many test cases so I decide to create a Pull Request to his repo and wait for his feedback.

Minh Quan wants me to change two points in the code:

The code after being changed
image

Then, he accepted my Pull Request.

4. Overall

All in all, this is an interesting lab, it gave us a chance to participate in other works and try our best to remain the author's style. Besides, Pull Requests and Review Code Changes are something fun to do. I enjoy this lab a lot. Thanks Minh Quan for your contribution.

Happy coding!

Top comments (0)