summaryrefslogtreecommitdiffstats
path: root/site.hs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2024-07-16 13:12:33 +0100
committerLibravatar cel 🌸 <cel@blos.sm>2024-07-16 13:12:33 +0100
commitfd0ea710395904e1b4cf5f22fd17af13db43ce5f (patch)
treec694efa675d3ad1daab3b1d9cfea737a805f1977 /site.hs
parente5e763f1d7d473b22d8c2e7f4a0058ada7832c24 (diff)
downloadinfoculture.pub-fd0ea710395904e1b4cf5f22fd17af13db43ce5f.tar.gz
infoculture.pub-fd0ea710395904e1b4cf5f22fd17af13db43ce5f.tar.bz2
infoculture.pub-fd0ea710395904e1b4cf5f22fd17af13db43ce5f.zip
webtorrent and teaser support
Diffstat (limited to 'site.hs')
-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