code cleanup

This commit is contained in:
Robert W. Pearce 2021-08-02 20:01:55 -04:00
parent f5b772c8ee
commit 38d24f08a9
No known key found for this signature in database
GPG Key ID: 07A0E482E5616C9B
2 changed files with 32 additions and 30 deletions

2
.ghci
View File

@ -4,4 +4,4 @@
:set -fno-warn-type-defaults -ferror-spans -freverse-errors -fprint-expanded-synonyms :set -fno-warn-type-defaults -ferror-spans -freverse-errors -fprint-expanded-synonyms
:set prompt "\ESC[0;32m%s\n\ESC[m[ghci]\ESC[38;5;172mλ \ESC[m\STX" :set prompt "\ESC[0;32m%s\n\ESC[m[ghci]\ESC[38;5;172mλ \ESC[m\STX"
:set prompt-cont " \ESC[38;5;172m> \ESC[m" :set prompt-cont " \ESC[38;5;172m> \ESC[m"
:load ssg/src/Slug.hs ssg/src/Main.hs :load ssg/src/Main.hs

View File

@ -17,6 +17,7 @@ import Text.Pandoc
) )
import Text.Pandoc.Highlighting (Style, breezeDark, styleToCss) import Text.Pandoc.Highlighting (Style, breezeDark, styleToCss)
--------------------------------------------------------------------------------
-- CONFIG -- CONFIG
root :: String root :: String
@ -30,29 +31,28 @@ siteName =
config :: Configuration config :: Configuration
config = config =
defaultConfiguration defaultConfiguration
{ destinationDirectory = "dist", { destinationDirectory = "dist"
ignoreFile = const False, , ignoreFile = const False
previewHost = "127.0.0.1", , previewHost = "127.0.0.1"
previewPort = 8000, , previewPort = 8000
providerDirectory = "src", , providerDirectory = "src"
storeDirectory = "ssg/_cache", , storeDirectory = "ssg/_cache"
tmpDirectory = "ssg/_tmp" , tmpDirectory = "ssg/_tmp"
} }
--------------------------------------------------------------------------------
-- BUILD -- BUILD
{- ORMOLU_DISABLE -}
main :: IO () main :: IO ()
main = hakyllWith config $ do main = hakyllWith config $ do
forM_ forM_
[ "CNAME", [ "CNAME"
"favicon.ico", , "favicon.ico"
"robots.txt", , "robots.txt"
"_config.yml", , "_config.yml"
"images/*", , "images/*"
"js/*", , "js/*"
"fonts/*" , "fonts/*"
] ]
$ \f -> match f $ do $ \f -> match f $ do
route idRoute route idRoute
@ -117,15 +117,14 @@ main = hakyllWith config $ do
compile (makeStyle pandocHighlightStyle) compile (makeStyle pandocHighlightStyle)
{- ORMOLU_ENABLE -} --------------------------------------------------------------------------------
-- COMPILER HELPERS -- COMPILER HELPERS
makeStyle :: Style -> Compiler (Item String) makeStyle :: Style -> Compiler (Item String)
makeStyle = makeStyle =
makeItem . compressCss . styleToCss makeItem . compressCss . styleToCss
--------------------------------------------------------------------------------
-- CONTEXT -- CONTEXT
feedCtx :: Context String feedCtx :: Context String
@ -145,6 +144,7 @@ titleCtx :: Context String
titleCtx = titleCtx =
field "title" updatedTitle field "title" updatedTitle
--------------------------------------------------------------------------------
-- TITLE HELPERS -- TITLE HELPERS
replaceAmp :: String -> String replaceAmp :: String -> String
@ -163,6 +163,7 @@ updatedTitle :: Item a -> Compiler String
updatedTitle = updatedTitle =
fmap replaceTitleAmp . getMetadata . itemIdentifier fmap replaceTitleAmp . getMetadata . itemIdentifier
--------------------------------------------------------------------------------
-- PANDOC -- PANDOC
pandocCompilerCustom :: Compiler (Item String) pandocCompilerCustom :: Compiler (Item String)
@ -173,11 +174,11 @@ pandocExtensionsCustom :: Extensions
pandocExtensionsCustom = pandocExtensionsCustom =
githubMarkdownExtensions githubMarkdownExtensions
<> extensionsFromList <> extensionsFromList
[ Ext_fenced_code_attributes, [ Ext_fenced_code_attributes
Ext_gfm_auto_identifiers, , Ext_gfm_auto_identifiers
Ext_implicit_header_references, , Ext_implicit_header_references
Ext_smart, , Ext_smart
Ext_footnotes , Ext_footnotes
] ]
pandocReaderOpts :: ReaderOptions pandocReaderOpts :: ReaderOptions
@ -214,13 +215,14 @@ feedCompiler renderer =
feedConfiguration :: FeedConfiguration feedConfiguration :: FeedConfiguration
feedConfiguration = feedConfiguration =
FeedConfiguration FeedConfiguration
{ feedTitle = "My Site", { feedTitle = "My Site"
feedDescription = "My Site Description", , feedDescription = "My Site Description"
feedAuthorName = "My Name", , feedAuthorName = "My Name"
feedAuthorEmail = "me@myemail.com", , feedAuthorEmail = "me@myemail.com"
feedRoot = root , feedRoot = root
} }
--------------------------------------------------------------------------------
-- CUSTOM ROUTE -- CUSTOM ROUTE
getTitleFromMeta :: Metadata -> String getTitleFromMeta :: Metadata -> String