code cleanup

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