aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flevum.cabal1
-rw-r--r--src/Main.hs70
-rw-r--r--templates/_includes/components/post.html2
3 files changed, 36 insertions, 37 deletions
diff --git a/flevum.cabal b/flevum.cabal
index a280e2e..d197a9c 100644
--- a/flevum.cabal
+++ b/flevum.cabal
@@ -19,6 +19,5 @@ executable flevum
pandoc ^>= 3.10,
process ^>= 1.6.13,
time,
- time-locale-compat ^>= 0.1.1,
wai-app-static ^>= 3.2
default-language: GHC2024
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
diff --git a/templates/_includes/components/post.html b/templates/_includes/components/post.html
index e901ec5..e27c0d5 100644
--- a/templates/_includes/components/post.html
+++ b/templates/_includes/components/post.html
@@ -14,7 +14,7 @@
$if(teaser)$
$teaser$
$else$
- $description$
+ $body$
$endif$
<p>
<a href="$url$" class="read-more-button" role="button">