.. | ||
index.js | ||
package-lock.json | ||
package.json | ||
readme.md |
Convert docx to Page
This script will take a docx file, attempt to convert it to a BookStack suitable format, then upload it into a BookStack book via the API.
This is a simplistic example of a NodeJS script. You will likely want to alter and extend this script to suit your use-case.
Requirements
You will need NodeJS installed (Tested on v14, may work on earlier versions). Images can be converted and uploaded via this but this requires Base64 image support by BookStack so you'll need to be using BookStack v21.05.1 or greater.
Running
First, download all the files in the same directory as this readme to a folder on your system and run the below from within that directory.
# Install NodeJS dependencies via NPM npm install # Setup # ALTERNATIVELY: Open the script and add to the empty strings in the variables at the top. export BS_URL=https://bookstack.example.com # Set to be your BookStack base URL export BS_TOKEN_ID=abc123 # Set to be your API token_id export BS_TOKEN_SECRET=123abc # Set to be your API token_secret # Running the script node index.js <docx_file> <book_slug>
<docx_file>
- File you want to convert & upload.<book_slug>
- The unique book identifier shown in the URL bar within BookStack (Autogenerated from the name).- For example:
- Book URL: https://example.com/books/bookstack-user-guide
- Book Slug: bookstack-user-guide
- For example:
Examples
# Convert the 'my_content.docx' file and upload to the Book with slug 'bookstack-user-guide' node index.js my_content.docx bookstack-user-guide