site.hs: Format with default LSP formatter

This commit is contained in:
Sanchayan Maity 2022-11-19 14:33:51 +05:30
parent 2490265685
commit 61f35bbb3a
1 changed files with 88 additions and 82 deletions

46
site.hs
View File

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