Projects page
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
--------------------------------------------------------------------------------
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE RecordWildCards #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
import Hakyll
|
||||
|
||||
import Data.List
|
||||
@ -39,6 +40,13 @@ main = hakyllWith defaultConfiguration{ignoreFile = ignore} $ do
|
||||
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
||||
>>= relativizeUrls
|
||||
|
||||
match "projects/*" $ do
|
||||
route $ setExtension "html"
|
||||
compile $ pandocCompiler
|
||||
>>= loadAndApplyTemplate "templates/project.html" postContext
|
||||
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
||||
>>= relativizeUrls
|
||||
|
||||
|
||||
match (fromList ["index.markdown", "contact.markdown"]) $ do
|
||||
route $ setExtension "html"
|
||||
@ -46,23 +54,23 @@ main = hakyllWith defaultConfiguration{ignoreFile = ignore} $ do
|
||||
>>= 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
|
||||
|
||||
archive $ Archive { output = "posts.html"
|
||||
, input = "posts/*"
|
||||
, title = "Posts"
|
||||
, template = "templates/post-list.html"
|
||||
, context = postContext
|
||||
}
|
||||
|
||||
archive $ Archive { output = "projects.html"
|
||||
, input = "projects/*"
|
||||
, title = "Projects"
|
||||
, template = "templates/project-list.html"
|
||||
, context = postContext
|
||||
}
|
||||
|
||||
match "templates/*" $ compile templateBodyCompiler
|
||||
where
|
||||
|
||||
postContext :: Context String
|
||||
postContext = dateField "date" "%B %e, %Y" <> defaultContext
|
||||
ignore :: FilePath -> Bool
|
||||
@ -73,6 +81,27 @@ main = hakyllWith defaultConfiguration{ignoreFile = ignore} $ do
|
||||
, (".swp" `isSuffixOf`)
|
||||
]
|
||||
|
||||
data Archive
|
||||
= Archive { output :: Identifier
|
||||
, input :: Pattern
|
||||
, title :: String
|
||||
, template :: Identifier
|
||||
, context :: Context String
|
||||
}
|
||||
|
||||
archive :: Archive -> Rules ()
|
||||
archive Archive{..} = create [output] $ do
|
||||
route idRoute
|
||||
compile $ do
|
||||
let itemsContext =
|
||||
listField "items" context items
|
||||
<> constField "title" title
|
||||
<> defaultContext
|
||||
items = recentFirst =<< loadAll input
|
||||
makeItem ""
|
||||
>>= loadAndApplyTemplate template itemsContext
|
||||
>>= loadAndApplyTemplate "templates/default.html" itemsContext
|
||||
>>= relativizeUrls
|
||||
|
||||
prepend :: a -> [a] -> [a]
|
||||
prepend = (:)
|
||||
|
Reference in New Issue
Block a user