From 86f7a15a2843f8c207124345d13969fb05ecc611 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 5 Nov 2025 09:33:23 +0100 Subject: Move themes files into the root directory --- src/Main.hs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs index fac40ac..861b9ce 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -56,7 +56,8 @@ import Hakyll.Web.Template.Context ) import Hakyll.Web.Template.List (recentFirst, sortRecentFirst) import System.FilePath - ( addTrailingPathSeparator + ( () + , addTrailingPathSeparator , joinPath , replaceExtension , splitDirectories @@ -66,16 +67,18 @@ import System.Process (rawSystem) import qualified Network.Wai.Application.Static as Static import Text.Pandoc.Options (HTMLMathMethod(..), WriterOptions(..)) --- -- -- Default configuration. -- +-- deployment.txt is expected to contain the remote deployment path +-- as its only content. +-- configuration :: Configuration configuration = Configuration { destinationDirectory = "./var/web" , storeDirectory = "./var/cache" , tmpDirectory = "./var/cache/tmp" - , providerDirectory = "./themes" + , providerDirectory = "." , watchIgnore = const False , ignoreFile = const False , deployCommand = "rsync" @@ -101,6 +104,12 @@ configuration = Configuration -- -- Helpers. -- +loadAndApplyLayout :: String -> Context String -> Item String -> Compiler (Item String) +loadAndApplyLayout layout context item = + let layoutPath = fromFilePath $ "templates/_layouts" layout + in loadAndApplyTemplate layoutPath context item + >>= loadAndApplyTemplate "templates/default.html" context + createIndex :: Tags -> Rules () createIndex tags = do paginate <- buildPaginateWith grouper "posts/**" makeId @@ -117,8 +126,7 @@ createIndex tags = do <> paginateContext paginate pageNumber <> flevumContext tags makeItem "" - >>= loadAndApplyTemplate "templates/blog.html" context - >>= loadAndApplyTemplate "templates/default.html" context + >>= loadAndApplyLayout "blog.html" context >>= cleanIndexUrls makeId 1 = "index.html" makeId pageNumber = fromFilePath $ shows pageNumber ".html" @@ -231,8 +239,7 @@ createTagPage tags tagName tagPattern = do <> flevumContext tags makeItem "" - >>= loadAndApplyTemplate "templates/tag.html" context - >>= loadAndApplyTemplate "templates/default.html" context + >>= loadAndApplyLayout "tag.html" context tagBase = fromFilePath . (("tags/" ++ tagName) ++) makeId 1 = tagBase "/index.html" makeId pageNumber = tagBase ('/' : shows pageNumber ".html") @@ -252,8 +259,7 @@ rules = do match "pages/*.tex" $ do route withoutRootRoute compile $ bibtexCompiler - >>= loadAndApplyTemplate "templates/page.html" contextWithTags - >>= loadAndApplyTemplate "templates/default.html" contextWithTags + >>= loadAndApplyLayout "page.html" contextWithTags >>= cleanIndexUrls -- Categories. @@ -264,16 +270,14 @@ rules = do route withoutRootRoute compile $ bibtexCompiler >>= saveSnapshot "content" - >>= loadAndApplyTemplate "templates/post.html" (postCtx tags) - >>= loadAndApplyTemplate "templates/default.html" (postCtx tags) + >>= loadAndApplyLayout "post.html" (postCtx tags) >>= cleanIndexUrls match "assets/bibliography/*.bib" $ compile biblioCompiler match "assets/bibliography/*.csl" $ compile cslCompiler -- Templates. - match (fromGlob "templates/*") $ compile templateBodyCompiler - match "_includes/**" $ compile templateBodyCompiler + match (fromGlob "templates/**") $ compile templateBodyCompiler -- Copy files. copyMatchedFiles "assets/fonts/*" -- cgit v1.2.3