Set up posts again
This commit is contained in:
@ -32,16 +32,40 @@ main = hakyllWith defaultConfiguration{ignoreFile = ignore} $ do
|
||||
route idRoute
|
||||
compile compressCssCompiler
|
||||
|
||||
match "posts/*" $ do
|
||||
route $ setExtension "html"
|
||||
compile $ pandocCompiler
|
||||
>>= loadAndApplyTemplate "templates/post.html" postContext
|
||||
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
||||
>>= relativizeUrls
|
||||
|
||||
|
||||
match (fromList ["index.markdown", "contact.markdown"]) $ do
|
||||
route $ setExtension "html"
|
||||
compile $ pandocCompiler
|
||||
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
||||
>>= relativizeUrls
|
||||
|
||||
create ["posts.html"] $ do
|
||||
route idRoute
|
||||
compile $ do
|
||||
let postsContext =
|
||||
listField "posts" postContext posts
|
||||
<> constField "title" "Posts"
|
||||
<> defaultContext
|
||||
posts = recentFirst =<< loadAll "posts/*"
|
||||
makeItem ""
|
||||
>>= loadAndApplyTemplate "templates/post-list.html" postsContext
|
||||
>>= loadAndApplyTemplate "templates/default.html" postsContext
|
||||
>>= relativizeUrls
|
||||
|
||||
|
||||
|
||||
match "templates/*" $ compile templateBodyCompiler
|
||||
where
|
||||
postContext :: Context String
|
||||
postContext = dateField "date" "%B %e, %Y" <> defaultContext
|
||||
ignore :: FilePath -> Bool
|
||||
ignore path = any ($ takeFileName path)
|
||||
[ ("." `isPrefixOf`)
|
||||
, ("#" `isPrefixOf`)
|
||||
|
@ -1,10 +1,10 @@
|
||||
{ mkDerivation, base, hakyll, stdenv, time }:
|
||||
{ mkDerivation, base, filepath, hakyll, stdenv, time }:
|
||||
mkDerivation {
|
||||
pname = "site";
|
||||
version = "0.1.0.0";
|
||||
src = ./.;
|
||||
isLibrary = false;
|
||||
isExecutable = true;
|
||||
executableHaskellDepends = [ base hakyll time ];
|
||||
executableHaskellDepends = [ base filepath hakyll time ];
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
}
|
||||
|
@ -13,5 +13,6 @@ executable site
|
||||
build-depends: base == 4.*
|
||||
, hakyll >= 4.10
|
||||
, time
|
||||
, filepath
|
||||
ghc-options: -threaded
|
||||
default-language: Haskell2010
|
||||
|
Reference in New Issue
Block a user