In this section, we are going to create a book in ePub format from the markdown content. The implementation steps should already be familiar to you now that you've gone through the HTML and PDF conversions.
On the browser side, let's slightly optimize the function so that we can run the conversion. Previously, we created separate functions, that is, generateHTML and generatePDF, to send a message to the generate channel.
If you take a look at the implementations of these functions carefully, you should notice that they only differ in terms of the format field. Instead of creating a third function called generateEPUB, I would suggest making the code more reusable.
Let's refactor our code and introduce the generateOutput function:
- Create the generateOutput function, which covers every generation scenario:
const generateOutput = (format, text...