site.hs: Format with default LSP formatter
This commit is contained in:
parent
2490265685
commit
61f35bbb3a
46
site.hs
46
site.hs
|
@ -1,8 +1,10 @@
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
import Data.Monoid (mappend)
|
import Data.Monoid (mappend)
|
||||||
import Hakyll
|
|
||||||
import qualified GHC.IO.Encoding as E
|
import qualified GHC.IO.Encoding as E
|
||||||
|
import Hakyll
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
@ -21,7 +23,8 @@ main = do
|
||||||
|
|
||||||
match (fromList ["about.markdown"]) $ do
|
match (fromList ["about.markdown"]) $ do
|
||||||
route $ setExtension "html"
|
route $ setExtension "html"
|
||||||
compile $ pandocCompiler
|
compile $
|
||||||
|
pandocCompiler
|
||||||
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
||||||
>>= relativizeUrls
|
>>= relativizeUrls
|
||||||
|
|
||||||
|
@ -29,7 +32,8 @@ main = do
|
||||||
|
|
||||||
match "posts/*" $ do
|
match "posts/*" $ do
|
||||||
route $ setExtension "html"
|
route $ setExtension "html"
|
||||||
compile $ pandocCompiler
|
compile $
|
||||||
|
pandocCompiler
|
||||||
>>= loadAndApplyTemplate "templates/post.html" (postCtxWithTags tags)
|
>>= loadAndApplyTemplate "templates/post.html" (postCtxWithTags tags)
|
||||||
>>= loadAndApplyTemplate "templates/default.html" (postCtxWithTags tags)
|
>>= loadAndApplyTemplate "templates/default.html" (postCtxWithTags tags)
|
||||||
>>= relativizeUrls
|
>>= relativizeUrls
|
||||||
|
@ -39,9 +43,9 @@ main = do
|
||||||
compile $ do
|
compile $ do
|
||||||
posts <- recentFirst =<< loadAll "posts/*"
|
posts <- recentFirst =<< loadAll "posts/*"
|
||||||
let archiveCtx =
|
let archiveCtx =
|
||||||
listField "posts" (postCtxWithTags tags) (return posts) `mappend`
|
listField "posts" (postCtxWithTags tags) (return posts)
|
||||||
constField "title" "Archives" `mappend`
|
`mappend` constField "title" "Archives"
|
||||||
defaultContext
|
`mappend` defaultContext
|
||||||
|
|
||||||
makeItem ""
|
makeItem ""
|
||||||
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
|
>>= loadAndApplyTemplate "templates/archive.html" archiveCtx
|
||||||
|
@ -53,10 +57,10 @@ main = do
|
||||||
compile $ do
|
compile $ do
|
||||||
posts <- fmap (take 3) . recentFirst =<< loadAll "posts/*"
|
posts <- fmap (take 3) . recentFirst =<< loadAll "posts/*"
|
||||||
let indexCtx =
|
let indexCtx =
|
||||||
listField "posts" (postCtxWithTags tags) (return posts) `mappend`
|
listField "posts" (postCtxWithTags tags) (return posts)
|
||||||
field "tags" (\_ -> renderTagList tags) `mappend`
|
`mappend` field "tags" (\_ -> renderTagList tags)
|
||||||
constField "title" "Welcome" `mappend`
|
`mappend` constField "title" "Welcome"
|
||||||
defaultContext
|
`mappend` defaultContext
|
||||||
|
|
||||||
getResourceBody
|
getResourceBody
|
||||||
>>= applyAsTemplate indexCtx
|
>>= applyAsTemplate indexCtx
|
||||||
|
@ -68,10 +72,10 @@ main = do
|
||||||
compile $ do
|
compile $ do
|
||||||
posts <- recentFirst =<< loadAll "posts/*"
|
posts <- recentFirst =<< loadAll "posts/*"
|
||||||
let sitemapCtx =
|
let sitemapCtx =
|
||||||
constField "baseUrl" "sanchayanmaity.net" `mappend`
|
constField "baseUrl" "sanchayanmaity.net"
|
||||||
constField "title" "Sitemap" `mappend`
|
`mappend` constField "title" "Sitemap"
|
||||||
listField "posts" (postCtxWithTags tags) (return posts) `mappend`
|
`mappend` listField "posts" (postCtxWithTags tags) (return posts)
|
||||||
postCtxWithTags tags
|
`mappend` postCtxWithTags tags
|
||||||
|
|
||||||
makeItem ""
|
makeItem ""
|
||||||
>>= loadAndApplyTemplate "templates/sitemap.xml" sitemapCtx
|
>>= loadAndApplyTemplate "templates/sitemap.xml" sitemapCtx
|
||||||
|
@ -84,7 +88,8 @@ main = do
|
||||||
route idRoute
|
route idRoute
|
||||||
compile $ do
|
compile $ do
|
||||||
posts <- recentFirst =<< loadAll pattern
|
posts <- recentFirst =<< loadAll pattern
|
||||||
let ctx = constField "title" title
|
let ctx =
|
||||||
|
constField "title" title
|
||||||
`mappend` listField "posts" (postCtxWithTags tags) (return posts)
|
`mappend` listField "posts" (postCtxWithTags tags) (return posts)
|
||||||
`mappend` defaultContext
|
`mappend` defaultContext
|
||||||
|
|
||||||
|
@ -95,14 +100,15 @@ main = do
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
config :: Configuration
|
config :: Configuration
|
||||||
config = defaultConfiguration {
|
config =
|
||||||
destinationDirectory = "public"
|
defaultConfiguration
|
||||||
}
|
{ destinationDirectory = "public"
|
||||||
|
}
|
||||||
|
|
||||||
postCtx :: Context String
|
postCtx :: Context String
|
||||||
postCtx =
|
postCtx =
|
||||||
dateField "date" "%B %e, %Y" `mappend`
|
dateField "date" "%B %e, %Y"
|
||||||
defaultContext
|
`mappend` defaultContext
|
||||||
|
|
||||||
postCtxWithTags :: Tags -> Context String
|
postCtxWithTags :: Tags -> Context String
|
||||||
postCtxWithTags tags = tagsField "tags" tags `mappend` postCtx
|
postCtxWithTags tags = tagsField "tags" tags `mappend` postCtx
|
||||||
|
|
Loading…
Reference in a new issue