ema-0.10.0.0: Static site generator library with hot reload
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ema.Site

Synopsis

Documentation

class IsRoute r => EmaSite r where Source #

Typeclass to orchestrate an Ema site

Given a route r from the class of IsRoute types, instantiating EmaSite on it enables defining the site build pipeline as follows:

 SiteArg -> siteInput -> Dynamic model --[r, model]--> siteOutput
 
  • SiteArg is typically not used, but it can be used to pass command line arguments and other such settings.
  • siteInput returns a time-varying value (Dynamic) representing the data for your static site.
  • siteOutput takes this data model (oneshot value) and returns the generated content (usually HTML asset, per SiteOutput) for the given route.

Finally, `Ema.App.runSite @r arg` (where arg is of type SiteArg) is run from the main entry point to run your Ema site.

Associated Types

type SiteArg r :: Type Source #

SiteArg is typically settings from the environment (config file, or command-line arguments) that your Dynamic-producing siteInput function consumes as argument.

type SiteArg r = ()

type SiteOutput r :: Type Source #

Type of the value returned by siteOutput. Usually `Asset LByteString` but it can be anything.

Methods

siteInput Source #

Arguments

:: forall m. (MonadIO m, MonadUnliftIO m, MonadLoggerIO m) 
=> Some Action 
-> SiteArg r

The value passed by the programmer to runSite

-> m (Dynamic m (RouteModel r))

Time-varying value of the model. If your model is not time-varying, use pure to produce a constant value.

Get the model's time-varying value as a Dynamic.

If your model is not time-varying, use pure to produce a constant value.

siteOutput :: forall m. (MonadIO m, MonadLoggerIO m) => Prism' FilePath r -> RouteModel r -> r -> m (SiteOutput r) Source #

Return the output (typically an Asset) for the given route and model.

Instances

Instances details
(EmaStaticSite r, EmaStaticSite (MultiRoute rs), SiteArg (MultiRoute rs) ~ NP I (MultiSiteArg rs), RouteModel (MultiRoute rs) ~ NP I (MultiModel rs)) => EmaSite (MultiRoute (r ': rs)) Source # 
Instance details

Defined in Ema.Route.Lib.Multi

Associated Types

type SiteArg (MultiRoute (r ': rs)) Source #

type SiteOutput (MultiRoute (r ': rs)) Source #

Methods

siteInput :: (MonadIO m, MonadUnliftIO m, MonadLoggerIO m) => Some Action -> SiteArg (MultiRoute (r ': rs)) -> m (Dynamic m (RouteModel (MultiRoute (r ': rs)))) Source #

siteOutput :: (MonadIO m, MonadLoggerIO m) => Prism' FilePath (MultiRoute (r ': rs)) -> RouteModel (MultiRoute (r ': rs)) -> MultiRoute (r ': rs) -> m (SiteOutput (MultiRoute (r ': rs))) Source #

EmaSite (MultiRoute ('[] :: [Type])) Source # 
Instance details

Defined in Ema.Route.Lib.Multi

Associated Types

type SiteArg (MultiRoute '[]) Source #

type SiteOutput (MultiRoute '[]) Source #

(EmaStaticSite r, KnownSymbol prefix) => EmaSite (FolderRoute prefix r) Source # 
Instance details

Defined in Ema.Route.Lib.Folder

Associated Types

type SiteArg (FolderRoute prefix r) Source #

type SiteOutput (FolderRoute prefix r) Source #

Methods

siteInput :: (MonadIO m, MonadUnliftIO m, MonadLoggerIO m) => Some Action -> SiteArg (FolderRoute prefix r) -> m (Dynamic m (RouteModel (FolderRoute prefix r))) Source #

siteOutput :: (MonadIO m, MonadLoggerIO m) => Prism' FilePath (FolderRoute prefix r) -> RouteModel (FolderRoute prefix r) -> FolderRoute prefix r -> m (SiteOutput (FolderRoute prefix r)) Source #

type EmaStaticSite r = (EmaSite r, SiteOutput r ~ Asset LByteString) Source #

Like EmaSite but SiteOutput is a bytestring Asset.