/docusaurus

Primary LanguageJavaScript

Markdown Book Genrator

Prerequisite

WebSite

How to run

  1. Clone the repository
    $ git clone https://github.com/bigbinary/markdown-book-generator.git
  2. Go to website directory
    $ cd website
  3. Install required node modules
    $ npm install
  4. Run Docusaurus Server It will generate the required files in docs/ folder and will open a website at port 3000
    $ npm start
  5. Building Static HTML Pages
    To create a static build of your website, run the following script from the website directory
    $ npm run build
    You can find your generated e-book at website/build folder.

you can delete docs folder as it's generated whenever you build the project

Hosting on Netlify

Steps to configure your Docusaurus-powered site on Netlify.

  1. Select New site from Git

  2. Connect to your preferred Git provider.

  3. Select the branch to deploy. Default is master

  4. Configure your build steps:

    • For your build command enter: cd website; npm install; npm run build;
    • For publish directory: website/build/<projectName> (use the projectName from your siteConfig)
  5. Click Deploy site

You can also configure Netlify to rebuild on every commit to your repository, or only master branch commits.

Adding a chapter

  1. Upload the chapter in chapter folder
  2. Add the entry of new chapter in chapter/ToC.json

Code-block customization

  1. To show line-number in code-block.
    just add 'line-numbers' in your code-block.
    ```ruby line-numbers
    def create
      @task = Task.new(task_params)
    ...
    ...
  2. To highlight a line in code block.
    just add the line number within '{}'. eg.,{2} or {1-4,3}
    ```ruby{4}
    def create
      @task = Task.new(task_params)
    ...
    ...

Key Files

  • Footer: The website/core/Footer.js file is a React component that acts as the footer for the site generated by Docusaurus and should be customized by the user.
  • Configuration file: The website/siteConfig.js file is the main configuration file used by Docusaurus.
  • Sidebars: The sidebars.json file contains the structure and order of the documentation files.
  • Highlighter: The website/static/js/highlighter.js file contains the code for highlighting.

Example

Highlighting && line nuumbers

```ruby{4}
def create
  @task = Task.new(task_params)
...
...

Ouput

Snapshot