aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-08-06 17:10:20 +0200
committerEugen Wissner <belka@caraus.de>2026-08-06 18:52:53 +0200
commit1c5ef0a9c52a273eb1b54ac9b8c8e2642b5c7376 (patch)
treef7be3e34d4279badedd3a8334c946673bbba80a0 /src
parent2f2da4ad81a290f38beb1f6fad2492d341c6fd51 (diff)
downloadflevum-1c5ef0a9c52a273eb1b54ac9b8c8e2642b5c7376.tar.gz
Remove bodyField and use the one given by defaultHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs70
1 files changed, 35 insertions, 35 deletions
diff --git a/src/Main.hs b/src/Main.hs
index d9b3cf5..61a44b5 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -5,8 +5,7 @@ module Main where
import Control.Monad (forM)
import Data.List (isPrefixOf, isSuffixOf)
-import Data.Time.Format (formatTime, FormatTime)
-import Data.Time.Locale.Compat (defaultTimeLocale)
+import Data.Time.Format (TimeLocale(..))
import Hakyll.Core.Compiler
( Compiler
, load
@@ -51,15 +50,13 @@ import Hakyll.Web.Template (loadAndApplyTemplate, templateBodyCompiler)
import Hakyll.Web.Template.Context
( Context(..)
, ContextField(..)
- , bodyField
, boolField
, constField
, defaultContext
, listField
, listFieldWith
- , field
+ , dateFieldWith
, teaserField
- , getItemUTC
)
import Hakyll.Web.Template.List (recentFirst, sortRecentFirst)
import System.FilePath
@@ -144,41 +141,44 @@ createIndex tags = createPaginatedPage indexRules "posts/**" ""
>>= loadAndApplyLayout "blog.html" context
>>= cleanIndexUrls
-localizeMonth :: String -> String
-localizeMonth "01" = "Januar"
-localizeMonth "02" = "Februar"
-localizeMonth "03" = "März"
-localizeMonth "04" = "April"
-localizeMonth "05" = "Mai"
-localizeMonth "06" = "Juni"
-localizeMonth "07" = "Juli"
-localizeMonth "08" = "August"
-localizeMonth "09" = "September"
-localizeMonth "10" = "Oktober"
-localizeMonth "11" = "November"
-localizeMonth "12" = "Dezember"
-localizeMonth _ = error "Invalid month number"
-
-formatDate :: FormatTime t => t -> String
-formatDate time
- = formatDefaultLocale "%e. "
- ++ localizeMonth (formatDefaultLocale "%m")
- ++ formatDefaultLocale " %Y"
- where
- formatDefaultLocale :: String -> String
- formatDefaultLocale = flip (formatTime defaultTimeLocale) time
+localizedTimeLocale :: TimeLocale
+localizedTimeLocale = TimeLocale
+ { wDays =
+ [ ("Sonntag", "So")
+ , ("Montag", "Mo")
+ , ("Dienstag", "Di")
+ , ("Mittwoch", "Mi")
+ , ("Donnerstag", "Do")
+ , ("Freitag", "Fr")
+ , ("Samstag", "Sa")
+ ]
+ , months =
+ [ ("Januar", "Jan.")
+ , ("Februar", "Feb.")
+ , ("März", "März")
+ , ("April", "Apr.")
+ , ("Mai", "Mai")
+ , ("Juni", "Jun.")
+ , ("Juli", "Jul.")
+ , ("August", "Aug.")
+ , ("September", "Sep.")
+ , ("Oktober", "Okt.")
+ , ("November", "Nov.")
+ , ("Dezember", "Dez.")
+ ]
+ , timeFmt = "%H:%M:%S"
+ , time12Fmt = "%I:%M:%S %p"
+ , knownTimeZones = []
+ , dateTimeFmt = "%a %b %e %H:%M:%S %Z %Y"
+ , dateFmt = "%d.%m.%y"
+ , amPm = ("AM", "PM")
+ }
postCtx :: Tags -> Context String
postCtx tags
- = field "published" dateField'
+ = dateFieldWith localizedTimeLocale "published" "%e. %B %Y"
<> teaserField "teaser" "content"
- <> bodyField "description"
<> flevumContext tags
- where
- dateField' :: Item String -> Compiler String
- dateField' = fmap formatDate
- . getItemUTC defaultTimeLocale
- . itemIdentifier
flevumContext :: Tags -> Context String
flevumContext = (<> defaultContext) . tagsCloud