-- | This is the main Hakyll module, exporting the important @hakyl@ function.---- Most configurations would use this @hakyll@ function more or less as the-- main function:---- > main = hakyll $ do-- > directory css "css"-- > directory static "images"--moduleText.Hakyll(defaultHakyllConfiguration,hakyll,hakyllWithConfiguration)whereimportControl.Monad.Reader(runReaderT,liftIO,ask)importControl.Concurrent(forkIO,threadDelay)importControl.Monad(when)importqualifiedData.MapasMimportSystem.Environment(getArgs,getProgName)importSystem.Directory(doesDirectoryExist,removeDirectoryRecursive)importSystem.Time(getClockTime)importText.PandocimportNetwork.Hakyll.SimpleServer(simpleServer)importText.Hakyll.HakyllMonadimportText.Hakyll.File-- | The default reader options for pandoc parsing.defaultPandocParserState::ParserStatedefaultPandocParserState=defaultParserState{-- The following option causes pandoc to read smart typography, a nice-- and free bonus.stateSmart=True}-- | The default writer options for pandoc rendering.defaultPandocWriterOptions::WriterOptionsdefaultPandocWriterOptions=defaultWriterOptions{-- This option causes literate haskell to be written using '>' marks in-- html, which I think is a good default.writerLiterateHaskell=True}-- | The default hakyll configuration.defaultHakyllConfiguration::HakyllConfigurationdefaultHakyllConfiguration=HakyllConfiguration{absoluteUrl="",additionalContext=M.empty,siteDirectory="_site",cacheDirectory="_cache",enableIndexUrl=False,previewPollDelay=1000000,pandocParserState=defaultPandocParserState,pandocWriterOptions=defaultPandocWriterOptions}-- | Main function to run Hakyll with the default configuration. The-- absolute URL is only used in certain cases, for example RSS feeds et-- cetera.hakyll::String-- ^ Absolute URL of your site. Used in certain cases.->Hakyll()-- ^ You code.->IO()hakyllabsolute=hakyllWithConfigurationconfigurationwhereconfiguration=defaultHakyllConfiguration{absoluteUrl=absolute}-- | Main function to run hakyll with a custom configuration.hakyllWithConfiguration::HakyllConfiguration->Hakyll()->IO()hakyllWithConfigurationconfigurationbuildFunction=doargs<-getArgsletf=caseargsof["build"]->buildFunction["clean"]->clean["preview",p]->previewbuildFunction(readp)["preview"]->previewbuildFunction8000["rebuild"]->clean>>buildFunction["server",p]->server(readp)["server"]->server8000_->helprunReaderTfconfiguration-- | Clean up directories.clean::Hakyll()clean=doaskHakyllsiteDirectory>>=remove'askHakyllcacheDirectory>>=remove'whereremove'dir=liftIO$doputStrLn$"Removing "++dir++"..."exists<-doesDirectoryExistdirwhenexists$removeDirectoryRecursivedir-- | Autocompile mode.preview::Hakyll()->Integer->Hakyll()previewbuildFunctionport=dobuildFunction_<-startServerliftIOgetClockTime>>=runwherestartServer=doconfiguration<-askliftIO$forkIO$runReaderT(serverport)configurationruntime=dodelay<-askHakyllpreviewPollDelayliftIO$threadDelaydelaycontents<-getRecursiveContents"."valid<-isMoreRecenttimecontentsifvalidthenruntimeelsedobuildFunctionliftIOgetClockTime>>=run-- | Show usage information.help::Hakyll()help=liftIO$doname<-getProgNameputStrLn$"This is a Hakyll site generator program. You should always\n"++"run it from the project root directory.\n"++"\n"++"Usage:\n"++name++" build Generate the site.\n"++name++" clean Clean up and remove cache.\n"++name++" help Show this message.\n"++name++" preview [port] Run a server and autocompile.\n"++name++" rebuild Clean up and build again.\n"++name++" server [port] Run a local test server.\n"-- | Start a server at the given port number.server::Integer->Hakyll()serverp=askHakyllsiteDirectory>>=liftIO.simpleServer(fromIntegralp)