b***@gmail.com
2015-09-14 14:04:44 UTC
I'd like to create a structure from the entire body of an identifier,
similar to buildTags and buildCategories, but there does not appear to be a
function to available to access the body of an identifier.
Here is buildTags:
buildTags :: MonadMetadata m => Pattern -> (String -> Identifier) -> m TagsbuildTags = buildTagsWith getTags
The important part here is getTags:
-- | Obtain tags from a page in the default way: parse them from the @tags@-- metadata field.getTags :: MonadMetadata m => Identifier -> m [String]getTags identifier = do metadata <- getMetadata identifier return $ maybe [] (map trim . splitAll ",") $ M.lookup "tags" metadata
Inside the MonadMetadata monad, we have access to metadata only. We can
cast a Pattern to a list of Identifiers with getMatches, but that's it.
Fetching an identifier's body is only possible in the Compiler context:
-- | Get the body of the underlying resourcegetResourceBody :: Compiler (Item String)getResourceBody = getResourceWith resourceBody
I want to be able to fetch the resource body, process it, and then return a
data structure like buildTags and buildCategories, which I can then pass
around:
*tags *<- buildTags "content/*/*" (fromCapture "tags/*")
categories <- buildCategories "content/*/*" (fromCapture "categories/*")
-- Elsewhere...
tagsRules *tags *$ \tag pattern -> do
let title = "Content tagged with " ++ tag
*(snip)*
Does anyone know if I can do this without having to add this functionality
to the MonadMetadata monad?
Kind Regards,
Beerend Lauwers
similar to buildTags and buildCategories, but there does not appear to be a
function to available to access the body of an identifier.
Here is buildTags:
buildTags :: MonadMetadata m => Pattern -> (String -> Identifier) -> m TagsbuildTags = buildTagsWith getTags
The important part here is getTags:
-- | Obtain tags from a page in the default way: parse them from the @tags@-- metadata field.getTags :: MonadMetadata m => Identifier -> m [String]getTags identifier = do metadata <- getMetadata identifier return $ maybe [] (map trim . splitAll ",") $ M.lookup "tags" metadata
Inside the MonadMetadata monad, we have access to metadata only. We can
cast a Pattern to a list of Identifiers with getMatches, but that's it.
Fetching an identifier's body is only possible in the Compiler context:
-- | Get the body of the underlying resourcegetResourceBody :: Compiler (Item String)getResourceBody = getResourceWith resourceBody
I want to be able to fetch the resource body, process it, and then return a
data structure like buildTags and buildCategories, which I can then pass
around:
*tags *<- buildTags "content/*/*" (fromCapture "tags/*")
categories <- buildCategories "content/*/*" (fromCapture "categories/*")
-- Elsewhere...
tagsRules *tags *$ \tag pattern -> do
let title = "Content tagged with " ++ tag
*(snip)*
Does anyone know if I can do this without having to add this functionality
to the MonadMetadata monad?
Kind Regards,
Beerend Lauwers
--
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "hakyll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hakyll+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.