A dead simple Node Express app that serves static Material Themed docs generated by Mkdocs from behind basic authentication.
- Clone this repo
- Install Node dependencies:
npm i(seepackage.json) - Run
npm startto see the current state of the ebook. - Start with
ebook-folder/mkdocs.ymlthis is the configuration file for this book
To be able to edit the ebook you will need to follow these steps first:
- Install Python 3.7+ on to your computer
- pip should be installed with Python but if not: install pip or
pip3 install pip cd ebook-folderto move into the Python package- run
git clone https://github.com/squidfunk/mkdocs-material.git - Install the Python Packages
pip3 install -r requirements.txt(Seerequirements.txt). - Run
mkdocs buildto build the markdown files into static HTML files into thesite/directory.
NOTE1: if you are running Python 2.7 this will not work. You'll need to update to Python 3.7 or higher.
NOTE2: if you are still running into the error your machine may have Python 2.7 set as a default. Change it to an alias so you alwasy use 3.7+ or change to alternative versions.
NOTE3: potential updates needed to Python packages, see
requirements.txt. Upgradedpymdown_extensions-8.1.1topymdown_extensions-9.4&mkdocs-1.1.2tomkdocs-1.3.0on May 10, 2022. runpip3 install <package> --upgrade
To serve the files in site/ to port 8000 withOUT username:password authentication simply run mkdocs serve.
To serve with authentication you'll need to add .env file with environment variables to the root directory:
cd ..echo "STUDENT_USERNAME=a-username STUDENT_PASSWORD=a-password INSTRUCTOR_USERNAME=a-username INSTRUCTOR_PASSWORD=a-password PORT=5500" >> .env
STUDENT_USERNAME=a-username
STUDENT_PASSWORD=a-password
INSTRUCTOR_USERNAME=a-username
INSTRUCTOR_PASSWORD=a-password
PORT=5500- From
ebook-folderrunmkdocs serve - From root directory run
npm start- to serve files fromsite/to port 5500 with username:password authentication
Go to
ebook-folder/mkdocs.ymlfor further instructions + seeebook-folder/workspacefor templates and notes.
While working in
ebook-folder/you can simply usemkdocs buildandmkdocs serveto by-pass the Node server.
- Finish your changes and check them with
mkdocs serve. - Before you
git addanything to staging runmkdocs build. This will ensure you've built the newest intended version of the ebook before you push it to GitHub. git status, add, commit, push ...to repo- Create pull request & merge
Heroku will need some environment variables to perform authentication checks. Add them as you would the variables in .env file using he CLI tools or the dashboard.
ENVIRONMENT:PRODUCTIONSTUDENT_USERNAME:<a-username>STUDENT_PASSWORD:<a-password>INSTRUCTOR_USERNAME:<a-username>INSTRUCTOR_PASSWORD:<a-password>
How to install Python and pip instructions here:
Mkdocs is a Python package that generates statics web files (HTML, CSS, JS), seen in the site/ directory, from plain Markdown files, seen in the docs/ directory.
Material-Mkdocs is another Python package that builds on top of Mkdocs to provide design from the Material-UI Theme. The two receive their configuration from the mkdocs.yaml file. You'll see the navigation is is provided by the nav: property in that file and the Material Theme is the value of theme:.
The Express server is just an app used to serve the static files from site/ behind basic authentication thus the Node app is deployed and not the Python code.