Quickly generate a wiki website from structured markdown files.
Table of contents
This cli is designed to be run inside a docker container.
The command below will:
- Read in markdown files from
- Write html files to
- Set the theme colour to
docker run -it --rm \ -v `pwd`/your_pages_directory:/pages \ -v `pwd`/your_output_directory:/dist \ openlab/wiki-md --theme-color="#4b8aee"
GitLab CI usage
Below is an example of using
wiki-md in a [GitLab CI] pipeline, it does a few things:
- Runs command inside the
- Offers customisation through pipeline variables
- Deploys assets to a server via SCP
- Authenticated with an ssh key added via pipeline variables
build_and_deploy: image: name: openlab/wiki-md:0.3.1 entrypoint: ['/bin/sh', '-c'] tags: - docker script: - wiki-md . dist --theme-color="$THEME_COLOR" --site-title="SOPs" - tar -czf dist.tar.gz dist - echo "$SSH_SECRET" > deploy_key && chmod 600 deploy_key - scp -o StrictHostKeyChecking=no -i deploy_key dist.tar.gz $DEPLOY_HOST:$DEPLOY_PATH/dist.tar.gz - ssh -o StrictHostKeyChecking=no -i deploy_key $DEPLOY_HOST $DEPLOY_PATH/update.sh
If you want to experiment you can install the cli with npm.
# Install it globally npm i -g @openlab/wiki-md # Use the cli wiki-md --help # For example... wiki-md pages dist --site-title="My wiki" --theme-color="#000000" --owner-name="Geoff" --owner-link="https://r0b.io" --verbose
Below is the cli
cli.js <indir> [outdir] Generate a site from local markdown files Commands: cli.js generate <indir> [outdir] Generate a site from local markdown files [default] cli.js serve <indir> [outdir] Generate a site, serve it locally and regenerate on changes Positionals: indir Where to recursively look for markdown files [string] outdir Where to put the generated html [string] [default: "dist"] Options: --version Show version number [boolean] --site-title The title of the site, used in the <title> elment [default: "Wiki"] --index-file What file to use to generate index.html files[default: "home"] --theme-color The primary theme color [default: "#23967F"] --theme-invert The inverse theme color, something contrasting themeColor [default: "#ffffff"] --base-path The base directory, if served in a folder [default: "/"] --owner-name The name of the owner of the site [default: "Open Lab"] --owner-link The link to the owner of the site [default: "https://openlab.ncl.ac.uk"] --verbose Whether to describe whats happening [boolean] [default: false] -h, --help Show help [boolean]
Below are instructions for developing this repo
To develop on this repo you will need to have Docker and node.js installed on your dev machine and have an understanding of them. This guide assumes you have the repo checked out and are on macOS, but equivalent commands are available.
You'll only need to follow this setup once for your dev machine.
# Install all dependencies using npm npm ci
These are the commands you'll regularly run to develop the API, in no particular order.
# Run the CLI # -> The -- is needed to that any args are passed to cli.js npm run dev -s -- # Output cli help npm run dev -s -- --help # Run a http server to serve files # -> Run in a new terminal tab npx http-server
These are commands you might need to run but probably won't, also in no particular order.
# Build the docker image VERSION=0.2.0 docker build -t openlab/wiki-md:$VERSION . docker push openlab/wiki-md:$VERSION # Lint the source code # -> Uses ESLint to check for common errors npm run lint # Format source code # -> Uses prettier to automatically format code # -> This already happens automatically when you commit (see below) npm run prettier # Generate the table of contents for this readme npx md-toc -i
This repo uses unit tests to ensure that everything is working correctly, guide development, avoid bad code and reduce defects.
The Jest package is used to run unit tests.
Tests are any file in
src/ that end with
.spec.js, by convention they are inline with the source code,
in a parallel folder called
# Run the tests npm test -s # Generate code coverage npm run coverage -s
This repo uses Prettier to automatically format code to a consistent standard. It works using the husky and lint-staged packages to automatically format code whenever code is commited. This means that code that is pushed to the repo is always formatted to a consistent standard.
You can manually run the formatter with
npm run prettier if you want.
This project was set up by puggle