diff options
Diffstat (limited to 'site.hs')
-rw-r--r-- | site.hs | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,7 +1,7 @@ -------------------------------------------------------------------------------- {-# LANGUAGE OverloadedStrings #-} import Data.Monoid (mappend) -import System.FilePath ((</>), (<.>), splitExtension, splitFileName, takeDirectory) +import System.FilePath ((</>), (<.>), splitExtension, splitFileName, takeDirectory, stripExtension, takeFileName, takeBaseName) import Hakyll @@ -20,6 +20,13 @@ main = hakyll $ do route idRoute compile copyFileCompiler + match "scripts/*" $ do + route idRoute + compile copyFileCompiler + + match "sw.min.js" $ do + route idRoute + compile copyFileCompiler match "style.css" $ do route idRoute @@ -128,6 +135,8 @@ postCtx :: Context String postCtx = constField "root" root `mappend` dateField "date" "%Y-%m-%d" `mappend` + idFieldFromPath "id" `mappend` + teaserField "teaser" "article-text" `mappend` dropIndexHtml "url" `mappend` defaultContext @@ -138,6 +147,11 @@ appendIndex :: Routes appendIndex = customRoute $ (\(p, e) -> p </> "index" <.> e) . splitExtension . toFilePath + +idFieldFromPath :: String -> Context a +idFieldFromPath key = mapContext transform (pathField key) where + transform path = takeBaseName path + dropIndexHtml :: String -> Context a dropIndexHtml key = mapContext transform (urlField key) where transform url = case splitFileName url of |