Compare commits
No commits in common. "6afa6d55d4fc77527ea37e5716db9a8ddfd66dcf" and "73b42aafa3cd4a2ac76c0c43a5058f9fde63ba4d" have entirely different histories.
6afa6d55d4
...
73b42aafa3
@ -7,6 +7,5 @@ executable site
|
||||
main-is: site.hs
|
||||
build-depends: base == 4.*
|
||||
, hakyll == 4.10.*
|
||||
, time
|
||||
ghc-options: -threaded
|
||||
default-language: Haskell2010
|
||||
|
58
site.hs
58
site.hs
@ -2,8 +2,6 @@
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
import Data.Monoid (mappend)
|
||||
import Hakyll
|
||||
import Data.List (sortBy, sortOn)
|
||||
import Data.Time (formatTime, defaultTimeLocale)
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@ -27,38 +25,34 @@ main = hakyll $ do
|
||||
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
||||
>>= relativizeUrls
|
||||
|
||||
match "posts/guides/*" $ do
|
||||
route $ setExtension "html"
|
||||
compile $ pandocCompiler
|
||||
>>= loadAndApplyTemplate "templates/post.html" postCtx
|
||||
>>= loadAndApplyTemplate "templates/default.html" postCtx
|
||||
>>= relativizeUrls
|
||||
-- match "posts/*" $ do
|
||||
-- route $ setExtension "html"
|
||||
-- compile $ pandocCompiler
|
||||
-- >>= loadAndApplyTemplate "templates/post.html" postCtx
|
||||
-- >>= loadAndApplyTemplate "templates/default.html" postCtx
|
||||
-- >>= relativizeUrls
|
||||
|
||||
match "posts/brainstorming/*" $ 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
|
||||
-- posts <- recentFirst =<< loadAll "posts/*"
|
||||
-- let archiveCtx =
|
||||
-- listField "posts" postCtx (return posts) `mappend`
|
||||
-- constField "title" "Archives" `mappend`
|
||||
-- defaultContext
|
||||
--
|
||||
-- makeItem ""
|
||||
-- >>= loadAndApplyTemplate "templates/archive.html" archiveCtx
|
||||
-- >>= loadAndApplyTemplate "templates/default.html" archiveCtx
|
||||
-- >>= relativizeUrls
|
||||
|
||||
create ["guides.html"] $ do
|
||||
route idRoute
|
||||
compile $ do
|
||||
posts <- modFirst =<< loadAll "posts/guides/*"
|
||||
let archiveCtx =
|
||||
listField "posts" postCtx (return posts) `mappend`
|
||||
constField "title" "Guides" `mappend`
|
||||
defaultContext
|
||||
|
||||
makeItem ""
|
||||
>>= loadAndApplyTemplate "templates/guides.html" archiveCtx
|
||||
>>= loadAndApplyTemplate "templates/default.html" archiveCtx
|
||||
>>= relativizeUrls
|
||||
|
||||
match "index.html" $ do
|
||||
route idRoute
|
||||
compile $ do
|
||||
posts <- recentFirst =<< loadAll "posts/*"
|
||||
let indexCtx =
|
||||
listField "posts" postCtx (return posts) `mappend`
|
||||
constField "title" "Home" `mappend`
|
||||
defaultContext
|
||||
|
||||
@ -69,19 +63,9 @@ main = hakyll $ do
|
||||
|
||||
match "templates/*" $ compile templateBodyCompiler
|
||||
|
||||
modFirst :: [Item a] -> Compiler [Item a]
|
||||
modFirst = fmap reverse . modified
|
||||
where
|
||||
modified = sortByM (getItemModificationTime . itemIdentifier)
|
||||
sortByM f xs = map fst . sortOn snd <$> mapM (\x -> (,) x <$> f x) xs
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
postCtx :: Context String
|
||||
postCtx =
|
||||
dateField "date" "%B %e, %Y" `mappend`
|
||||
modifiedField "modified" "%B %e, %Y" `mappend`
|
||||
defaultContext
|
||||
where
|
||||
modifiedField key format = field key $ \i -> do
|
||||
time <- getItemModificationTime $ itemIdentifier i
|
||||
return $ formatTime defaultTimeLocale format time
|
||||
|
2
templates/archive.html
Normal file
2
templates/archive.html
Normal file
@ -0,0 +1,2 @@
|
||||
Here you can find all my previous posts:
|
||||
$partial("templates/post-list.html")$
|
@ -14,7 +14,6 @@
|
||||
</div>
|
||||
<nav>
|
||||
<a href="/">Home</a>
|
||||
<a href="/guides.html">Guides</a>
|
||||
<a href="/about.html">About</a>
|
||||
<a href="/contact.html">Contact</a>
|
||||
</nav>
|
||||
|
@ -1,3 +0,0 @@
|
||||
A list of small and big guides.
|
||||
|
||||
$partial("templates/post-list.html")$
|
@ -1,6 +1,6 @@
|
||||
<article>
|
||||
<section class="header">
|
||||
Posted on $date$, modified on $modified$
|
||||
Posted on $date$
|
||||
$if(author)$
|
||||
by $author$
|
||||
$endif$
|
||||
|
Loading…
Reference in New Issue
Block a user