more dir parameters

This commit is contained in:
Mirek Kratochvil 2023-06-08 14:42:11 +02:00
parent c6d86aeed3
commit 384e56cb53
4 changed files with 16 additions and 4 deletions

View file

@ -44,6 +44,8 @@ data SiteState =
, _templates :: M.Map FilePath Mu.Template
, _outputDir :: FilePath -- ^ Directory for output
, _assetDir :: FilePath -- ^ Directory for output
, _sourceDir :: FilePath -- ^ Path to page source data
, _templateDir :: FilePath -- ^ Path to template directory
, _defaultTemplate :: FilePath -- ^ Name of the default template
, _redirectTemplate :: FilePath -- ^ Name of the template for redirect pages
, _tagTemplate :: FilePath -- ^ Name of the template for tag listing pages
@ -71,7 +73,17 @@ siteOptions' = do
short 'a' <>
help "Assets directory to be copied verbatim" <>
value "assets" <> showDefault
--TODO templates directory!
_sourceDir <-
strOption $
long "source-directory" <>
short 's' <>
help "Path to the directory with source data (possibly multiple paths)" <>
value "cards" <> showDefault
_templateDir <-
strOption $
long "template-directory" <>
help "Path to the directory with templates" <>
value "templates" <> showDefault
_defaultTemplate <-
strOption $
long "default-template" <>

View file

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View file

@ -23,6 +23,7 @@ import Hakyll.Core.Util.File (getRecursiveContents, makeDirectories)
import Lens.Micro
import Lens.Micro.Aeson
import Lens.Micro.Mtl
import qualified Options.Applicative
import System.FilePath
( (</>)
, isAbsolute
@ -36,7 +37,6 @@ import Text.Pandoc.Class (runIOorExplode)
import Text.Pandoc.Readers.Markdown (readMarkdown)
import Text.Pandoc.Writers.HTML (writeHtml5String)
import qualified Text.Parsec.Error
import qualified Options.Applicative
import FormatOpts
import Types
@ -321,9 +321,9 @@ main = do
init <- Options.Applicative.execParser siteOptions
flip runStateT init $ do
installAssets
traverse sourcePages ["external"]
use sourceDir >>= sourcePages
sourceTags
sourceTemplates "templates"
use templateDir >>= sourceTemplates
use pages >>= traverse (uncurry installPage) . M.assocs
renderTags
io $ putStrLn "OK"