Browse Source

code cleanup

main
Robert W. Pearce 1 year ago
parent
commit
38d24f08a9
No known key found for this signature in database
GPG Key ID: 7A0E482E5616C9B
  1. 2
      .ghci
  2. 60
      ssg/src/Main.hs

2
.ghci

@ -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

60
ssg/src/Main.hs

@ -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 = "[email protected]",
feedRoot = root
{ feedTitle = "My Site"
, feedDescription = "My Site Description"
, feedAuthorName = "My Name"
, feedAuthorEmail = "[email protected]"
, feedRoot = root
}
--------------------------------------------------------------------------------
-- CUSTOM ROUTE
getTitleFromMeta :: Metadata -> String

Loading…
Cancel
Save