3 This script will take a docx file,
4 attempt to convert it to a BookStack suitable format, then upload
5 it into a BookStack book via the API.
7 This is a simplistic example of a NodeJS script. You will likely want to
8 alter and extend this script to suit your use-case.
12 You will need NodeJS installed (Tested on v14, may work on earlier versions).
13 Images can be converted and uploaded via this but this requires Base64 image support
14 by BookStack so you'll need to be using BookStack v21.05.1 or greater.
18 First, download all the files in the same directory as this readme to a folder on your system
19 and run the below from within that directory.
22 # Install NodeJS dependencies via NPM
26 # ALTERNATIVELY: Open the script and add to the empty strings in the variables at the top.
27 export BS_URL=https://bookstack.example.com # Set to be your BookStack base URL
28 export BS_TOKEN_ID=abc123 # Set to be your API token_id
29 export BS_TOKEN_SECRET=123abc # Set to be your API token_secret
32 node index.js <docx_file> <book_slug>
35 - `<docx_file>` - File you want to convert & upload.
36 - `<book_slug>` - The unique book identifier shown in the URL bar within BookStack (Autogenerated from the name).
38 - Book URL: https://example.com/books/bookstack-user-guide
39 - Book Slug: bookstack-user-guide
44 # Convert the 'my_content.docx' file and upload to the Book with slug 'bookstack-user-guide'
45 node index.js my_content.docx bookstack-user-guide