53bd4e7461c412c7d0aa4fd5405e5035c3dfaba3 — Case Duckworth 3 months ago 771333c master
Add tagType field for templating
1 files changed, 6 insertions(+), 1 deletions(-)

M src/Acdw/Tags.hs
M src/Acdw/Tags.hs => src/Acdw/Tags.hs +6 -1
@@ 30,6 30,8 @@ data TagsRules =
   TagsRules
     { tagTitle       :: String -> String
         -- ^ how to build a title from the tag name
+    , tagType        :: String
+        -- ^ internal name of tag type (i.e., "tag", "category", etc.
     , tagCapture     :: String -> Identifier
         -- ^ function to capture the tag (like fromCapture "tag/*.html")
     , tagTemplates   :: [Identifier]


@@ 44,6 46,7 @@ defaultTR :: TagsRules
 defaultTR =
   TagsRules
     { tagTitle = id
+    , tagType = "tag"
     , tagCapture = fromCapture "tag/*.html"
     , tagTemplates =
         ["templates/archive.html", "templates/body.html", "templates/head.html"]


@@ 58,12 61,13 @@ tagTR =
 
 categoryTR :: TagsRules
 categoryTR =
-  defaultTR {tagTitle = pluralize, tagCapture = fromCapture "*/index.html"}
+  defaultTR {tagTitle = pluralize, tagType = "category", tagCapture = fromCapture "*/index.html"}
 
 seriesTR :: TagsRules
 seriesTR =
   defaultTR
     { tagTitle = \(s:e) -> "Series: " ++ toUpper s : e
+    , tagType = "series"
     , tagCapture = fromCapture "series/*/index.html"
     , tagSort = chronological
     }


@@ 78,6 82,7 @@ createTags tags tr =
       let ctx =
             mconcat
               [ constField "title" $ tagTitle tr tag
+              , constField "tag-type" $ tagType tr
               , listField
                   "posts"
                   (mconcat [mconcat $ tagExtraFields tr, postCtx])