Skip to content

Instantly share code, notes, and snippets.

@serialhex
Last active December 11, 2015 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serialhex/4662061 to your computer and use it in GitHub Desktop.
Save serialhex/4662061 to your computer and use it in GitHub Desktop.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>My Hakyll Blog - about</title>
<link rel="stylesheet" type="text/css" href="./css/default.css" />
</head>
<body>
<div id="header">
<div id="logo">
<a href="./">Dihydrogen Monoxide Poisoning</a>
</div>
<div id="navigation">
<a href="./">Home</a>
<a href="./about.html">About</a>
<a href="./contact.html">Contact</a>
<a href="./archive.html">Archive</a>
</div>
</div>
<div id="content">
<h1>about</h1>
<p>moar aboot me
title
about

moar aboot me' it ezz sexi!!!

serialhex@multi-hex [~/src/serialhex.net]$ ./site build -v [ruby-1.9.3-p194]
Initialising...
Creating store...
site: _site/about.html: commitBuffer: invalid argument (invalid character)
Creating provider...
Running rules...
Checking for out-of-date items
[DEBUG] about.md is out-of-date because it is new
[DEBUG] archive.html is out-of-date because it is new
[DEBUG] contact.md is out-of-date because it is new
[DEBUG] css/default.css is out-of-date because it is new
[DEBUG] images/haskell-logo.png is out-of-date because it is new
[DEBUG] index.html is out-of-date because it is new
[DEBUG] posts/2013-01-28-its-been-a-long-time.markdown is out-of-date because it is new
[DEBUG] posts/2013-01-28-reasons.md is out-of-date because it is new
[DEBUG] templates/archive.html is out-of-date because it is new
[DEBUG] templates/default.html is out-of-date because it is new
[DEBUG] templates/post-item.html is out-of-date because it is new
[DEBUG] templates/post.html is out-of-date because it is new
Compiling
[DEBUG] Processing about.md
[DEBUG] Require templates/default.html: chasing
[DEBUG] Processing templates/default.html
updated templates/default.html
[DEBUG] Processing about.md
[DEBUG] Require templates/default.html: OK
[DEBUG] Processing about.md
updated about.md
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative ((<$>))
import Data.Monoid (mappend)
import Hakyll
--------------------------------------------------------------------------------
main :: IO ()
main = hakyll $ do
match "images/*" $ do
route idRoute
compile copyFileCompiler
match "css/*" $ do
route idRoute
compile compressCssCompiler
match (fromList ["about.md", "contact.md"]) $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
match "posts/*" $ do
route $ setExtension "html"
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/post.html" postCtx
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
create ["archive.html"] $ do
route idRoute
compile $ do
let archiveCtx =
field "posts" (\_ -> postList recentFirst) `mappend`
constField "title" "Archives" `mappend`
defaultContext
makeItem ""
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
>>= loadAndApplyTemplate "templates/default.html" archiveCtx
>>= relativizeUrls
match "index.html" $ do
route idRoute
compile $ do
let indexCtx = field "posts" $ \_ -> postList (take 3 . recentFirst)
getResourceBody
>>= applyAsTemplate indexCtx
>>= loadAndApplyTemplate "templates/default.html" postCtx
>>= relativizeUrls
match "templates/*" $ compile templateCompiler
--------------------------------------------------------------------------------
postCtx :: Context String
postCtx =
dateField "date" "%B %e, %Y" `mappend`
defaultContext
--------------------------------------------------------------------------------
postList :: ([Item String] -> [Item String]) -> Compiler String
postList sortFilter = do
posts <- sortFilter <$> loadAll "posts/*"
itemTpl <- loadBody "templates/post-item.html"
list <- applyTemplateList itemTpl postCtx posts
return list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment