From 1c5ef0a9c52a273eb1b54ac9b8c8e2642b5c7376 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 6 Aug 2026 17:10:20 +0200 Subject: Remove bodyField and use the one given by default --- src/Main.hs | 70 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'src/Main.hs') 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 -- cgit v1.2.3