-- | Once a target is compiled, the user usually wants to save it to the disk.-- This is where the 'Routes' type comes in; it determines where a certain-- target should be written.---- Suppose we have an item @foo\/bar.markdown@. We can render this to-- @foo\/bar.html@ using:---- > route "foo/bar.markdown" (setExtension ".html")---- If we do not want to change the extension, we can use 'idRoute', the simplest-- route available:---- > route "foo/bar.markdown" idRoute---- That will route @foo\/bar.markdown@ to @foo\/bar.markdown@.---- Note that the extension says nothing about the content! If you set the-- extension to @.html@, it is your own responsibility to ensure that the-- content is indeed HTML.---- Finally, some special cases:---- * If there is no route for an item, this item will not be routed, so it will-- not appear in your site directory.---- * If an item matches multiple routes, the first rule will be chosen.--moduleHakyll.Core.Routes(Routes,runRoutes,idRoute,setExtension,ifMatch,customRoute)whereimportData.Monoid(Monoid,mempty,mappend)importControl.Monad(mplus)importSystem.FilePath(replaceExtension)importHakyll.Core.IdentifierimportHakyll.Core.Identifier.Pattern-- | Type used for a route--newtypeRoutes=Routes{unRoutes::Identifier->MaybeFilePath}instanceMonoidRouteswheremempty=Routes$constNothingmappend(Routesf)(Routesg)=Routes$\id'->fid'`mplus`gid'-- | Apply a route to an identifier--runRoutes::Routes->Identifier->MaybeFilePathrunRoutes=unRoutes-- | A route that uses the identifier as filepath. For example, the target with-- ID @foo\/bar@ will be written to the file @foo\/bar@.--idRoute::RoutesidRoute=Routes$Just.toFilePath-- | Set (or replace) the extension of a route.---- Example:---- > runRoute (setExtension "html") "foo/bar"---- Result:---- > Just "foo/bar.html"---- Example:---- > runRoute (setExtension "html") "posts/the-art-of-trolling.markdown"---- Result:---- > Just "posts/the-art-of-trolling.html"--setExtension::String->RoutessetExtensionextension=Routes$fmap(`replaceExtension`extension).unRoutesidRoute-- | Modify a route: apply the route if the identifier matches the given-- pattern, fail otherwise.--ifMatch::Pattern->Routes->RoutesifMatchpattern(Routesroute)=Routes$\id'->ifdoesMatchpatternid'thenrouteid'elseNothing-- | Create a custom route. This should almost always be used with 'ifMatch'.--customRoute::(Identifier->FilePath)->RoutescustomRoutef=Routes$Just.f