pencil
Static site generator
https://github.com/elben/pencil
| LTS Haskell 14.27: | 1.0.1@rev:1 |
| Stackage Nightly 2019-09-21: | 1.0.1@rev:1 |
| Latest on Hackage: | 1.0.1@rev:1 |
pencil-1.0.1@sha256:785f97977d9138ef789bfe4289724251a1586f001c82dfd4e10d3e4ef4764a04,6611Module documentation for 1.0.1
Pencil
Pencil is a static site generator. Use Pencil to build a personal website, a blog, and more. Pencil comes pre-loaded with goodies such as Markdown and Sass/Scss support, templating, blogging, and tagging. Designed with the Haskell beginner in mind, but flexible enough to extend for your own needs.
The easiest way to get started is to read the tutorials at elbenshira.com/pencil and reference the Haddock docs.
The blue-backed notebooks, the two pencils and the pencil sharpener… the marble topped tables, the smell of early morning… and luck were all you needed. — Ernest Hemingway, A Moveable Feast
Examples
Here’s an example that shows a personal website with a blog and an RSS feed. Based off the this example.
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Pencil
config :: Config
config =
updateEnv (insertText "title" "My Awesome Website") defaultConfig
website :: PencilApp ()
website = do
layout <- load "layout.html"
index <- load "index.markdown"
render (layout <|| index)
loadAndRender "stylesheet.scss"
main :: IO ()
main = run website config
You can check out other examples. The Blog is a good one.
My personal website (http://elbenshira.com) uses Pencil (source here). And so does Pencil’s website at elbenshira.com/pencil (source here).
Development
See DEVELOPMENT.md
Changes
CHANGELOG
All notable changes to this project will be documented in this file.
Unreleased
1.0.1
Tests were failing from the sdist distribution due to missing files in
extra-source-files. Add them.
1.0.0
This is a milestone release! Version 1.0.0. Several breaking changes, but if you read through the changes below, you should find updating your code to be pretty easy. Please email me if you are having problems!
Added
- Added GHC 8.4 and 8.6 support.
- Added
(<<|)andcollto add collection values into structrues. - Added
useFilePath,escapeXml,rename,to,moveto manipulate loadedPages. - Added
loadAndRenderconvenience method. Supports individual files and directories. You’ll want to use this one to move over static assets quickly and easily:loadAndRender "images/". - Added
toTextRssandrfc822DateFormatto render content ready for an RSS template. See the Blog example for details.
Changed
- All of the
Pencil.Blogfunctions are now re-exported inPencil. So you only need toimport Pencilnow. loadnow automatically figures out the desired final FilePath, so it doesn’t take a(FilePath -> FilePath)as the first argument anymore. You can change your code fromload toHtml "foo.markdown"toload "foo.markdown", for the most part. Useload'to manually specify the FilePath transform. See examples in the Hackage docs forload',to,moveandrename.loadResources, likeload, no longers takes a file path transformer. Useto,moveorrenameto change the file path. But really, you probably can useloadDirorloadDir'orloadAndRenderinstead ofloadResources.- Renamed
structuretostruct. It’s shorter. passthroughnow works with directories too.insertPagesreturn type changed fromEnvtoPencilApp Env. We now evaluate the given pages (e.g. replace variables) before inserting into env. So you’ll need to change fromlet env' = insertPages "posts" posts envtoenv <- insertPages "posts" posts env.- Renamed
updateEnvValtoadjust. - Renamed
insertEnvtoinsert. - Renamed
injectTagsEnvtoinjectTags. - Renamed
arrayContainsStringtoarrayContainsText. - Changed how structures work internally to allow collection values into structures.
- Examples now match the tutorials. This is the start of merging the tutorials into the pencil repo itself, instead of living somewhere else.
- Two new errors:
CollectionNotLastInStructureandCollectionFirstInStructureto handle collection positions in structures.
Fixed
- Specify example test files in the pencil.cabal file, so that pencil tests run properly.
Removed
renderCss. UseloadAndRenderinstead. As in:loadAndRender "style.scss"- Removed
VarNotInEnverror type, since Pencil no longer throws that.
0.1.3
Changed
- Updated dependencies. Should be able to use with recent versions of Stack LTS releases and Nix channels.
- Pandoc updated to 2.5 from 1.x. Source code renders using
<a>tags now, so you may have to change your CSS. If you want CSS to target only<a href>tags, usea[href] { ... }.
0.1.2
Added
- Escape template directives using
$${example}. This will be rendered literally as${example}.
0.1.1
Added
- Blog example.
- Minor method changes.
Changed
- Bounds changed for ghc 8.0.2 and 8.2.2 support.
- Improved documentation.
0.1.0
Added
- First release.
0.0.0
Added
Changed
Fixed
Removed
Deprecated
Security
The format is based on Keep a Changelog.