Fixed image previews just in time to not want Hakyll anymore
This commit is contained in:
parent
41ba569234
commit
f12c4b3773
27
site.hs
27
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 entry point for generating all code via Hakyll
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
E.setLocaleEncoding E.utf8
|
E.setLocaleEncoding E.utf8
|
||||||
hakyll $ do
|
hakyll $ do
|
||||||
--hakyllWithArgs config options $ do
|
--hakyllWithArgs config options $ do tags
|
||||||
-- Build up tags
|
|
||||||
tags <- buildTags "posts/*" (fromCapture "tags/*.html")
|
tags <- buildTags "posts/*" (fromCapture "tags/*.html")
|
||||||
let postCtxTags = postCtxWithTags tags
|
let postCtxTags = postCtxWithTags tags
|
||||||
|
|
||||||
@ -67,12 +69,13 @@ main = do
|
|||||||
route idRoute
|
route idRoute
|
||||||
compile copyFileCompiler
|
compile copyFileCompiler
|
||||||
|
|
||||||
-- But also, make 640x480 reduced versions with /thumbnail
|
-- But also, make reduced versions with (e.g.) that replace
|
||||||
-- prepended to their path:
|
-- "foo.jpg" with ".reduced.jpg":
|
||||||
match ("images/**.jpg" .||. "images/**.png") $ version "thumbnail" $ do
|
match ("images/**.jpg" .||. "images/**.png") $ version "reduced" $ do
|
||||||
route $ customRoute $ combine "./thumbnail/" . toFilePath
|
--route $ customRoute $ combine "./thumbnail/" . toFilePath
|
||||||
|
route $ customRoute $ reducedExtn . toFilePath
|
||||||
compile $ loadImage
|
compile $ loadImage
|
||||||
>>= scaleImageCompiler 640 480
|
>>= scaleImageCompiler 500 500
|
||||||
|
|
||||||
-- (I don't fully understand what role "version" plays here except
|
-- (I don't fully understand what role "version" plays here except
|
||||||
-- that it appears to be required for me to have two matches on
|
-- that it appears to be required for me to have two matches on
|
||||||
@ -161,8 +164,16 @@ main = do
|
|||||||
route idRoute
|
route idRoute
|
||||||
compile $ do
|
compile $ do
|
||||||
posts <- recentFirst =<< loadAllSnapshots "works/*" "content"
|
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 =
|
let archiveCtx =
|
||||||
listField "works" postCtxTags (return posts) `mappend`
|
listField "works" ctxt2 (return posts) `mappend`
|
||||||
constField "title" "Something" `mappend`
|
constField "title" "Something" `mappend`
|
||||||
defaultContext
|
defaultContext
|
||||||
makeItem ""
|
makeItem ""
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<h3>$title$</h3>
|
<h3>$title$</h3>
|
||||||
<a href="$img$">
|
<a href="$img$">
|
||||||
<img src="$img$" class="img-responsive"/>
|
<img src="$imgpreview$" class="img-responsive"/>
|
||||||
</a>
|
</a>
|
||||||
<!-- N.B. use img-fluid for Bootstrap 4 -->
|
<!-- N.B. use img-fluid for Bootstrap 4 -->
|
||||||
$if(description)$
|
$if(description)$
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user