diff options
| author | Eugen Wissner <belka@caraus.de> | 2025-11-05 09:33:23 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2025-11-05 09:33:23 +0100 |
| commit | 86f7a15a2843f8c207124345d13969fb05ecc611 (patch) | |
| tree | d0850ce1f334093f70a06eec5de97fb8b54372c2 /src | |
| parent | 80e0fe22d28687f3599a949f1a4d29171b12b20f (diff) | |
| download | flevum-86f7a15a2843f8c207124345d13969fb05ecc611.tar.gz | |
Move themes files into the root directory
Diffstat (limited to 'src')
| -rw-r--r-- | src/Main.hs | 30 |
1 files changed, 17 insertions, 13 deletions
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 @@ -67,15 +68,17 @@ 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/*" |
