Added experimental match & route to resize images to previews

It does not yet *use* the previews, it just puts them into a path with
'thumbnail' prepended.  Thanks, hakyll-gallery, for the inspiration.
This commit is contained in:
Chris Hodapp 2020-01-24 18:23:37 -05:00
parent c119faea4a
commit 41ba569234
3 changed files with 20 additions and 1 deletions

View File

@ -7,6 +7,7 @@ executable site
main-is: site.hs
build-depends: base == 4.*
, hakyll >= 4.6
, hakyll-images >= 0.4.4
, filepath
, containers
, pandoc

19
site.hs
View File

@ -9,6 +9,7 @@ Portability : POSIX
{-# LANGUAGE OverloadedStrings #-}
import Data.Monoid (mappend)
import Hakyll
import Hakyll.Images
import System.FilePath
import Text.Pandoc.Options
import qualified GHC.IO.Encoding as E
@ -61,7 +62,23 @@ main = do
tags <- buildTags "posts/*" (fromCapture "tags/*.html")
let postCtxTags = postCtxWithTags tags
match ("images/**" .||. "assets/**" .||. "assets_external/**" .||. "css/*" .||. "js/**") $ do
-- Pass through all full-size images:
match ("images/**") $ version "full" $ 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
compile $ loadImage
>>= scaleImageCompiler 640 480
-- (I don't fully understand what role "version" plays here except
-- that it appears to be required for me to have two matches on
-- the same file paths.)
match ("assets/**" .||. "assets_external/**" .||. "css/*" .||. "js/**") $ do
route idRoute
compile copyFileCompiler

View File

@ -7,3 +7,4 @@ nix:
packages: [zlib]
extra-deps:
- hakyll-images-0.4.4