diff --git a/site.hs b/site.hs index 5c70563..2d58c31 100644 --- a/site.hs +++ b/site.hs @@ -52,13 +52,15 @@ options = Options { verbosity = True } } +reducedExtn :: FilePath -> FilePath +reducedExtn x = replaceExtension x (".reduced" ++ takeExtension x) + -- | Main entry point for generating all code via Hakyll main :: IO () main = do E.setLocaleEncoding E.utf8 hakyll $ do - --hakyllWithArgs config options $ do - -- Build up tags + --hakyllWithArgs config options $ do tags tags <- buildTags "posts/*" (fromCapture "tags/*.html") let postCtxTags = postCtxWithTags tags @@ -67,12 +69,13 @@ main = do route idRoute compile copyFileCompiler - -- But also, make 640x480 reduced versions with /thumbnail - -- prepended to their path: - match ("images/**.jpg" .||. "images/**.png") $ version "thumbnail" $ do - route $ customRoute $ combine "./thumbnail/" . toFilePath + -- But also, make reduced versions with (e.g.) that replace + -- "foo.jpg" with ".reduced.jpg": + match ("images/**.jpg" .||. "images/**.png") $ version "reduced" $ do + --route $ customRoute $ combine "./thumbnail/" . toFilePath + route $ customRoute $ reducedExtn . toFilePath compile $ loadImage - >>= scaleImageCompiler 640 480 + >>= scaleImageCompiler 500 500 -- (I don't fully understand what role "version" plays here except -- that it appears to be required for me to have two matches on @@ -161,8 +164,16 @@ main = do route idRoute compile $ do posts <- recentFirst =<< loadAllSnapshots "works/*" "content" + let getExtn x = do + s <- getMetadataField' (itemIdentifier x) "img" + return $ reducedExtn s + -- TODO: Can't I make this a simpler (well... maybe) + -- one-liner? + let ctxt2 = postCtxTags `mappend` (field "imgpreview" getExtn) + -- Why does this work? I guess imgpreview needs to be + -- inside the listField (given how I use it). let archiveCtx = - listField "works" postCtxTags (return posts) `mappend` + listField "works" ctxt2 (return posts) `mappend` constField "title" "Something" `mappend` defaultContext makeItem "" diff --git a/templates/post-grid.html b/templates/post-grid.html index 96f50cd..b07c910 100644 --- a/templates/post-grid.html +++ b/templates/post-grid.html @@ -4,7 +4,7 @@