-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to Hakyll 4 and fix that damn indenting
- Loading branch information
Showing
22 changed files
with
119 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,58 @@ | ||
{-# LANGUAGE Arrows, OverloadedStrings #-} | ||
import Control.Arrow | ||
{-# LANGUAGE OverloadedStrings #-} | ||
import Control.Applicative | ||
import Control.Monad | ||
import Data.Monoid | ||
import Hakyll | ||
import Text.Pandoc | ||
|
||
main :: IO () | ||
main = hakyll $ do | ||
match "templates/*.html" $ compile templateCompiler | ||
match "templates/*" $ | ||
compile $ templateCompiler | ||
|
||
match "css/***.css" $ route idRoute >> compile copyFileCompiler | ||
match "img/***" $ route idRoute >> compile copyFileCompiler | ||
match "css/***.css" $ do | ||
route idRoute | ||
compile copyFileCompiler | ||
|
||
match "img/***" $ do | ||
route idRoute | ||
compile copyFileCompiler | ||
|
||
match "posts/***.md" $ do | ||
route $ setExtension "html" | ||
compile $ (pageCompilerWith defaultParserState withToc) | ||
>>> arr (renderDateField "date" "%Y-%m-%d" "Date Unknown") | ||
>>> applyTemplateCompiler "templates/post.html" | ||
>>> applyTemplateCompiler "templates/default.html" | ||
>>> relativizeUrlsCompiler | ||
compile $ pandocCompiler | ||
>>= saveSnapshot "content" | ||
>>= loadAndApplyTemplate "templates/post.html" defaultContext | ||
>>= loadAndApplyTemplate "templates/default.html" defaultContext | ||
>>= relativizeUrls | ||
|
||
match "index.html" $ route idRoute | ||
create "index.html" $ constA mempty | ||
>>> arr (setField "title" "Posts") | ||
>>> setFieldPageList recentFirst | ||
"templates/postitem.html" "posts" "posts/*" | ||
>>> applyTemplateCompiler "templates/posts.html" | ||
>>> applyTemplateCompiler "templates/default.html" | ||
>>> relativizeUrlsCompiler | ||
create ["index.html"] $ do | ||
route idRoute | ||
compile $ do | ||
posts <- recentFirst <$> loadAll "posts/*" | ||
postItem <- loadBody "templates/postitem.html" | ||
postStr <- applyTemplateList postItem defaultContext posts | ||
makeItem "" | ||
>>= loadAndApplyTemplate "templates/posts.html" | ||
(constField "posts" postStr <> defaultContext) | ||
>>= loadAndApplyTemplate "templates/default.html" | ||
(constField "title" "Posts" <> defaultContext) | ||
>>= relativizeUrls | ||
|
||
match "posts.rss" $ route idRoute | ||
create "posts.rss" $ | ||
requireAll_ "posts/*" | ||
>>> mapCompiler (arr $ copyBodyToField "description") | ||
>>> renderRss feedConfiguration | ||
create ["posts.rss"] $ do | ||
route idRoute | ||
compile $ do | ||
posts <- take 10 . recentFirst <$> loadAllSnapshots "posts/*" "content" | ||
renderRss feedConfiguration | ||
(bodyField "description" <> defaultContext) | ||
posts | ||
where | ||
postContext = dateField "date" "%Y-%m-%d" | ||
|
||
feedConfiguration = FeedConfiguration | ||
{ feedTitle = "Inside ocharles" | ||
, feedDescription = "MusicBrainz hacker. Haskell geek. Wannabe mathematician. Electronic music fanatic." | ||
, feedAuthorName = "Oliver Charles" | ||
, feedRoot = "http://ocharles.org.uk/blog" | ||
, feedAuthorEmail = "ollie@ocharles.org.uk" | ||
} | ||
|
||
withToc = defaultWriterOptions | ||
{ writerTableOfContents = True | ||
, writerTemplate = "<div id=\"TOC\"><h2>Table of contents</h2>\n$toc$</div>$body$" | ||
, writerStandalone = True | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.