summaryrefslogtreecommitdiffstats
path: root/site.hs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--site.hs16
1 files changed, 15 insertions, 1 deletions
diff --git a/site.hs b/site.hs
index b8ad4b3..8284c2f 100644
--- a/site.hs
+++ b/site.hs
@@ -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