diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Hakyll/Core/Compiler.hs | 8 | ||||
-rw-r--r-- | src/Hakyll/Web/Tags.hs | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/Hakyll/Core/Compiler.hs b/src/Hakyll/Core/Compiler.hs index 70e9a37..7fe1754 100644 --- a/src/Hakyll/Core/Compiler.hs +++ b/src/Hakyll/Core/Compiler.hs @@ -89,6 +89,7 @@ module Hakyll.Core.Compiler ( Compiler , runCompiler , getIdentifier + , getIdentifiers , getRoute , getRouteFor , getResourceString @@ -165,6 +166,13 @@ runCompiler compiler identifier provider routes store modified logger = do getIdentifier :: Compiler a Identifier getIdentifier = fromJob $ const $ CompilerM $ compilerIdentifier <$> ask +-- | Get all identifiers matching the given pattern +-- +getIdentifiers :: Pattern -> Compiler a [Identifier] +getIdentifiers pattern = fromJob $ const $ CompilerM $ + matches pattern . map unResource . resourceList + . compilerResourceProvider <$> ask + -- | Get the route we are using for this item -- getRoute :: Compiler a (Maybe FilePath) diff --git a/src/Hakyll/Web/Tags.hs b/src/Hakyll/Web/Tags.hs index c971b0f..32076a0 100644 --- a/src/Hakyll/Web/Tags.hs +++ b/src/Hakyll/Web/Tags.hs @@ -40,7 +40,6 @@ module Hakyll.Web.Tags import Prelude hiding (id) import Control.Category (id) import Control.Applicative ((<$>)) -import Data.Map (Map) import qualified Data.Map as M import Data.List (intersperse, intercalate) import Control.Arrow (arr, (&&&), (>>>), (***), (<<^), returnA) @@ -65,7 +64,7 @@ import Hakyll.Core.Util.String -- | Data about tags -- data Tags a = Tags - { tagsMap :: Map String [Page a] + { tagsMap :: [(String, [Page a])] } deriving (Show, Typeable) instance Binary a => Binary (Tags a) where @@ -91,7 +90,8 @@ readTagsWith :: (Page a -> [String]) -- ^ Function extracting tags from a page -> [Page a] -- ^ Pages -> Tags a -- ^ Resulting tags readTagsWith f pages = Tags - { tagsMap = foldl (M.unionWith (++)) M.empty (map readTagsWith' pages) + { tagsMap = M.toList $ + foldl (M.unionWith (++)) M.empty (map readTagsWith' pages) } where -- Create a tag map for one page @@ -122,7 +122,7 @@ renderTags :: (String -> Identifier) renderTags makeUrl makeItem concatItems = proc (Tags tags) -> do -- In tags' we create a list: [((tag, route), count)] tags' <- mapCompiler ((id &&& (getRouteFor <<^ makeUrl)) *** arr length) - -< M.toList tags + -< tags let -- Absolute frequencies of the pages freqs = map snd tags' |