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:
parent
c119faea4a
commit
41ba569234
@ -7,6 +7,7 @@ executable site
|
|||||||
main-is: site.hs
|
main-is: site.hs
|
||||||
build-depends: base == 4.*
|
build-depends: base == 4.*
|
||||||
, hakyll >= 4.6
|
, hakyll >= 4.6
|
||||||
|
, hakyll-images >= 0.4.4
|
||||||
, filepath
|
, filepath
|
||||||
, containers
|
, containers
|
||||||
, pandoc
|
, pandoc
|
||||||
|
|||||||
19
site.hs
19
site.hs
@ -9,6 +9,7 @@ Portability : POSIX
|
|||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
import Data.Monoid (mappend)
|
import Data.Monoid (mappend)
|
||||||
import Hakyll
|
import Hakyll
|
||||||
|
import Hakyll.Images
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import Text.Pandoc.Options
|
import Text.Pandoc.Options
|
||||||
import qualified GHC.IO.Encoding as E
|
import qualified GHC.IO.Encoding as E
|
||||||
@ -61,7 +62,23 @@ main = do
|
|||||||
tags <- buildTags "posts/*" (fromCapture "tags/*.html")
|
tags <- buildTags "posts/*" (fromCapture "tags/*.html")
|
||||||
let postCtxTags = postCtxWithTags tags
|
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
|
route idRoute
|
||||||
compile copyFileCompiler
|
compile copyFileCompiler
|
||||||
|
|
||||||
|
|||||||
@ -7,3 +7,4 @@ nix:
|
|||||||
packages: [zlib]
|
packages: [zlib]
|
||||||
|
|
||||||
extra-deps:
|
extra-deps:
|
||||||
|
- hakyll-images-0.4.4
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user