Skip to content
Generate a html page from markdown and serve it over http with docker
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tools
.dockerignore
.editorconfig
.eslintrc.yml
.gitignore
.prettierrc.yml
Dockerfile
README.md
REGISTRY
package-lock.json
package.json
page.md

README.md

Static Page

For when you want to quickly throw up a not-so-terrible-looking html page and you only want to write markdown. This repo is a node.js app which compiles assets with unified, remark and rehype, styles them with bulma then deploys them with docker.

Table of Contents

An example

Say you want a quick holding page and you have a markdown file with content in, content.md.

---
title: Coming Soon
subtitle: You'll have to wait a little bit longer
theme: #6b2636
---

# Coming Soon

Etiam porta sem malesuada magna mollis euismod. Etiam porta sem malesuada magna mollis euismod. Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.

Then you want to quickly deploy it using docker:

docker run -it --rm \
  -v `pwd`/content.md:/app/page.md
  -p 3000:3000
  robb-j/static-page:1.1.0

Then all you have to do is visit http://localhost:3000

Customisation

Frontmatter

There are currently 3 values you can set in the frontmatter

  • titlerequired The title of the page
  • subtitle – An optional subtitle of the page
  • theme – A css colour for the theme of the page

Favicon

You can override the favicon by docker bind-mounting it to /app/src/favicon.png.

Development

Setup

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.

Commands

# Install npm packages
npm i

# Run the development server
# -> It will compile the html & css and server them at localhost:3000
# -> It watches for file changes using `nodemon` and restarts the server
npm run dev

# Generate the table of contents for this readme
npm run gen-readme-toc

Code formatting

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.

Prettier is slightly configured in .prettierrc.yml and also ignores files using .prettierignore.

Deployment

Building the image

This repo uses an npm postversion script to build, tag and push the docker image to dockerhub. Use the npm version command to create a new version and it will build and push a new docker image with that version. This means that all images are semantically versioned. The :latest docker tag is not used.

# Deploy a new version of the CLI
npm version # major | minor | patch
git push --tags

Future work

  • Watch for file changes and regenerate the in-memory page

This repo was setup with robb-j/node-base

You can’t perform that action at this time.