Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Usage

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:

get the latest version tag here

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

Then visit http://localhost:3000

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.

Healthcheck

There is a healthcheck endpoint at /healthz which will return a http/200 if all is clear. If the server is terminating it will return a http/503.

GET /healthz

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.

Releasing

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

About

Generate a html page from markdown and serve it over http with docker

Resources

Packages

No packages published