Re: [hakyll] Generating thumbnail image list

151 views
Skip to first unread message

Samuel Tardieu

unread,
Apr 2, 2013, 5:23:31 AM4/2/13
to hak...@googlegroups.com



2013/4/2 <tim....@gmail.com>

In the tutorial, the output from that function is bound inside of a context that is used when generating the enclosing page.  So, I have a template that describes a thumbnail snippet.  I also have a data structure that gives me the filename of the image along with some extra meta information I use in the template.  What I then do, is

thumbnail :: Painting -> Compiler (Item String)
thumbnail p = do 
  makeItem "" >>=
    loadAndApplyTemplate "templates/thumbnail.html" (thumbCtx p)

where my thumbCtx function takes the data structure I referred to above and builds out the appropriate context object.  Note the problem.  I have a Compiler (Item String) rather than a Compiler String.

I'll just answer this part here: you can get a "Compiler String" from a "Compiler (Item String)" by lifting "itemBody :: Item a -> a" into the Compiler monad, by adding ">>= return . itemBody" to your chain of expression or by using "fmap itemBody $" (or "itemBody <$>") before "loadAndApplyTemplate".

  Sam

Timothy Braje

unread,
Apr 2, 2013, 8:01:56 PM4/2/13
to hak...@googlegroups.com
That's exactly what I was missing.  Thanks!
Reply all
Reply to author
Forward
0 new messages