module Rules.Blog.Paginate.YearlyPosts ( build ) where import Control.Monad.Reader (asks) import Control.Monad.Trans (MonadTrans (..)) import Hakyll import Archives (YearlyArchives, archivesRules) import Config.Blog (BlogConfig (..)) import Rules.Blog.ListPage (ListPageOpts, listPage) import Rules.Blog.Paginate.Utils import Rules.Blog.Type import qualified Vendor.FontAwesome as FA build :: FA.FontAwesomeIcons -> Tags -> ListPageOpts -> BlogConfReader Rules Rules YearlyArchives build :: FontAwesomeIcons -> Tags -> ListPageOpts -> BlogConfReader Rules Rules YearlyArchives build FontAwesomeIcons faIcons Tags tags ListPageOpts listPageOpts = do YearlyArchives yearlyArchives <- (BlogConfig Rules -> Rules YearlyArchives) -> ReaderT (BlogConfig Rules) Rules (Rules YearlyArchives) forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a asks BlogConfig Rules -> Rules YearlyArchives forall (m :: * -> *). BlogConfig m -> m YearlyArchives blogYearlyArchivesBuilder ReaderT (BlogConfig Rules) Rules (Rules YearlyArchives) -> (Rules YearlyArchives -> BlogConfReader Rules Rules YearlyArchives) -> BlogConfReader Rules Rules YearlyArchives forall a b. ReaderT (BlogConfig Rules) Rules a -> (a -> ReaderT (BlogConfig Rules) Rules b) -> ReaderT (BlogConfig Rules) Rules b forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b >>= Rules YearlyArchives -> BlogConfReader Rules Rules YearlyArchives forall (m :: * -> *) a. Monad m => m a -> ReaderT (BlogConfig Rules) m a forall (t :: (* -> *) -> * -> *) (m :: * -> *) a. (MonadTrans t, Monad m) => m a -> t m a lift [Identifier] -> Rules [[Identifier]] grouper' <- BlogConfReader Rules Rules ([Identifier] -> Rules [[Identifier]]) forall (m :: * -> *) (f :: * -> *) (n :: * -> *). (Monad m, MonadMetadata f, MonadFail f) => BlogConfReader n m ([Identifier] -> f [[Identifier]]) grouper FilePath -> PageNumber -> Identifier makeId' <- (BlogConfig Rules -> FilePath -> FilePath) -> BlogConfReader Rules Rules (FilePath -> PageNumber -> Identifier) forall (n :: * -> *) (m :: * -> *) a. Monad n => (BlogConfig m -> a -> FilePath) -> BlogConfReader m n (a -> PageNumber -> Identifier) makeId BlogConfig Rules -> FilePath -> FilePath forall (m :: * -> *). BlogConfig m -> FilePath -> FilePath blogYearlyPagePath Rules () -> ReaderT (BlogConfig Rules) Rules () forall (m :: * -> *) a. Monad m => m a -> ReaderT (BlogConfig Rules) m a forall (t :: (* -> *) -> * -> *) (m :: * -> *) a. (MonadTrans t, Monad m) => m a -> t m a lift (Rules () -> ReaderT (BlogConfig Rules) Rules ()) -> Rules () -> ReaderT (BlogConfig Rules) Rules () forall a b. (a -> b) -> a -> b $ YearlyArchives -> (FilePath -> Pattern -> Rules ()) -> Rules () forall a. Archives a -> (a -> Pattern -> Rules ()) -> Rules () archivesRules YearlyArchives yearlyArchives ((FilePath -> Pattern -> Rules ()) -> Rules ()) -> (FilePath -> Pattern -> Rules ()) -> Rules () forall a b. (a -> b) -> a -> b $ \FilePath year Pattern pat -> let title' :: FilePath title' = FilePath -> FilePath -> FilePath title FilePath "Yearly" FilePath year in ([Identifier] -> Rules [[Identifier]]) -> Pattern -> (PageNumber -> Identifier) -> Rules Paginate forall (m :: * -> *). MonadMetadata m => ([Identifier] -> m [[Identifier]]) -> Pattern -> (PageNumber -> Identifier) -> m Paginate buildPaginateWith [Identifier] -> Rules [[Identifier]] grouper' Pattern pat (FilePath -> PageNumber -> Identifier makeId' FilePath year) Rules Paginate -> (Paginate -> Rules ()) -> Rules () forall a b. Rules a -> (a -> Rules b) -> Rules b forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b >>= Maybe FilePath -> FontAwesomeIcons -> Tags -> ListPageOpts -> Paginate -> Rules () listPage (FilePath -> Maybe FilePath forall a. a -> Maybe a Just FilePath title') FontAwesomeIcons faIcons Tags tags ListPageOpts listPageOpts YearlyArchives -> BlogConfReader Rules Rules YearlyArchives forall a. a -> ReaderT (BlogConfig Rules) Rules a forall (f :: * -> *) a. Applicative f => a -> f a pure YearlyArchives yearlyArchives