This content originally appeared on DEV Community and was authored by TueNguyen2911
I had a chance to contribute to IPC144, a work in progress which aims to upgrade the current IPC144 website using Docusaurus.
The issue:
I chose a pretty interesting issue to work on which asked me to convert the website into a pdf, the future students would be able to take notes partly thanks to me, yay!
Solving the issue:
I took a look at a few packages that convert Docusaurus website into a pdf and I came to a conclusion to using mr-pdf as it supported Docusaurus v.2 and had multiple options.
Using mr-pdf
I created a shell script to run a line of command to convert the website into a pdf and added the script to the scripts
of package.json
.
#!/usr/bin/env bash
npx mr-pdf
--initialDocURLs="http://localhost:3000"
--contentSelector="article"
--paginationSelector=".pagination-nav__item--next > a" --excludeSelectors=".margin-vert--xl a,.theme-edit-this-page,.tocCollapsible_1PrD theme-doc-toc-mobile tocMobile_3Hoh,.tocCollapsibleButton_2O1e"
--coverImage="https://download.logo.wine/logo/
Seneca_College/Seneca_College-Logo.wine.png"
--coverTitle="IPC144"
--outputPDFFilename "Seneca-IPC144.pdf"
Another issue came up, as mr-pdf
required a running instance of the website (initialDocURLs
), the pagination target (paginationSelector
), I needed to create a way for the project to build
and serve
.
Creating a way to automatic build
, serve
and convert
I wrote a Javascript file that used execa
to handle child processes and wait-on
to wait for resources on the localhost
to be available and then converted the page into a pdf. Killing the port was the last thing to do.
Conclusion
My PR technically was working but I had to to spend quite a while fix to meet the standard, and I made a bunch of small, syntactic errors. Some of which I didn't know but thanks to the experience, I think I will not make those mistakes again.
This content originally appeared on DEV Community and was authored by TueNguyen2911
TueNguyen2911 | Sciencx (2021-11-20T05:23:25+00:00) Contributing to Seneca OER. Retrieved from https://www.scien.cx/2021/11/20/contributing-to-seneca-oer/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.