Link tags directly to a directory with a trailing slash
This commit is contained in:
14
src/Main.hs
14
src/Main.hs
@@ -177,18 +177,18 @@ tagsCloud tags
|
|||||||
$ forM (tagsMap tags) . go
|
$ forM (tagsMap tags) . go
|
||||||
where
|
where
|
||||||
categoryContextF "title" _ = pure . StringField . categoryTitle
|
categoryContextF "title" _ = pure . StringField . categoryTitle
|
||||||
categoryContextF "url" _ = pure . StringField . ("/" ++) . categoryTitle
|
categoryContextF "url" _ = pure . StringField
|
||||||
|
. ('/' :) . (++ "/") . categoryTitle
|
||||||
categoryContextF "body" _ = pure . StringField . itemBody
|
categoryContextF "body" _ = pure . StringField . itemBody
|
||||||
categoryContextF key _ = const $ noResult $ "Tried field " ++ key
|
categoryContextF key _ = const $ noResult $ "Tried field " ++ key
|
||||||
categoryTitle = last . directoryNames . itemIdentifier
|
categoryTitle = last . directoryNames . itemIdentifier
|
||||||
directoryNames = init . splitDirectories .toFilePath
|
directoryNames = init . splitDirectories . toFilePath
|
||||||
go :: Item String -> (String, [Identifier]) -> Compiler (Item FilePath)
|
go :: Item String -> (String, [Identifier]) -> Compiler (Item FilePath)
|
||||||
go Item{ itemIdentifier = currentPage } tag = do
|
go Item{ itemIdentifier = currentPage } (tag, _) = do
|
||||||
let tagId = tagsMakeId tags $ fst tag
|
let tagId = tagsMakeId tags tag
|
||||||
tagsMetadata <- getMetadataField currentPage "tags"
|
tagsMetadata <- getMetadataField currentPage "tags"
|
||||||
let isActiveClass
|
let isActiveClass = directoryNames currentPage == directoryNames tagId
|
||||||
= directoryNames currentPage == directoryNames tagId
|
|| Just tag == tagsMetadata
|
||||||
|| Just (fst tag) == tagsMetadata
|
|
||||||
pure $ Item tagId $ if isActiveClass then "active" else ""
|
pure $ Item tagId $ if isActiveClass then "active" else ""
|
||||||
|
|
||||||
withoutRootRoute :: Routes
|
withoutRootRoute :: Routes
|
||||||
|
|||||||
Reference in New Issue
Block a user