/leaf-press

Static site generator based on Vapor's Leaf. Blog-aware and Markdown aware.

Primary LanguageSwiftMIT LicenseMIT

LeafPress

Static site generator based on Vapor's Leaf. Blog-aware and Markdown aware.

Install

Linux

Statically linked binary. Known to work on Debian and Ubuntu

cd /usr/local/bin \
&& curl -L https://github.com/danramteke/leaf-press/releases/download/0.6.0leaf-press-ubuntu-20.04.tgz | tar xzf - \
&& cd -

leaf-press init
leaf-press build

macOS Big Sur

cd /usr/local/bin \
&& curl -L https://github.com/danramteke/leaf-press/releases/download/0.6.0/leaf-press-macos-11.0.tgz | tar xzf - \
&& cd -

leaf-press init
leaf-press build

macOS Catalina

cd /usr/local/bin \
&& curl -L https://github.com/danramteke/leaf-press/releases/download/0.6.0/leaf-press-macos-10.15.tgz | tar xzf -
&& cd -

leaf-press init
leaf-press build

Build from source

git clone https://github.com/danramteke/leaf-press.git 
cd leaf-press

swift run leaf-press init 
swift run leaf-press build 

Docker

docker run -it --rm -v `pwd`:`pwd` -w `pwd` --platform linux/amd64 danramteke/leaf-press:0.6.0 leaf-press build

Or for development

docker run -it --rm -v `pwd`:`pwd` -w `pwd` --platform linux/amd64 swift:5.4-focal sh

Mint

mint install danramteke/leaf-press
leaf-press build

or

mint run danramteke/leaf-press leaf-press build

Getting Started

After the binary is installed locally, leaf-press init will scaffold a fresh website for you.

After making changes, run leaf-press build

To scaffold a new blog post, with today's date as the default, run leaf-press new

Although leaf-press serve isn't implemented yet, it prints out a docker command pointed at your current output directory.

LeafPress is built on Leaf, Vapor's templating engine. Here is the Leaf documentionation.

Config options

Configuration is stored in leaf-press.yml.

  • distDir: path to output dir, relative to leaf-press.yml
  • postsPublishPrefix: prefix for blog posts. For example if you want them to render to a posts folder or a blog folder
  • pagesDir: path to pages directory, relative to leaf-press.yml. Pages are standalone pages on the website
  • postsDir: path to posts directory, relative to leaf-press.yml. Posts need to have a date, and are considered chronological.
  • staticFilesDir: path to static files. These are copied into the output directory without any processing. Useful for images, or for other assets that don't need processing.
  • templatesDir: path to templates
  • postBuildScript can be used to run minification or CSS helpers.

Example Projects

Here are some projects live examples for reference, since sample projects don't always stay up to date.

GitLab Pages:

GitHub Pages:

Development Setup

After cloning the repo, generate an Xcode project with swift package generate-xcodeproj. When adding or removing tests, remember to run swift test --generate-linuxmain before committing and pushing your changes.

Branching Strategy

  • main is the mainline branch. May be unstable.
  • x.x.x tags are releases. Creating a tag will trigger a release build in github actions and on dockerhub.