slug generation improvements

This commit is contained in:
rhiannon morris 2024-09-15 17:39:37 +02:00
parent 32edbb1816
commit 0438ee590f
2 changed files with 9 additions and 5 deletions

View File

@ -25,10 +25,14 @@ getOptionsWith hdr mkDef descrs = do
exitFailure exitFailure
makeSlug :: Text -> Text makeSlug :: Text -> Text
makeSlug name = Text.map toSlugChar name where makeSlug = Text.intercalate "-" . filter (not . Text.null) . chunks where
toSlugChar c chunks txt =
| isAlphaNum c && isAscii c || c == '-' = toLower c if Text.null txt then [] else
| otherwise = '_' let (this', that') = Text.span isOK txt
this = Text.map toLower this'
that = Text.dropWhile (not . isOK) that' in
this : chunks that
isOK c = (isAlphaNum c && isAscii c) || c == '-'
toTextList :: MetaValue -> Maybe [Text] toTextList :: MetaValue -> Maybe [Text]

View File

@ -2,7 +2,7 @@
<ul class=tag-list> <ul class=tag-list>
$for(all-tags)$ $for(all-tags)$
<li> <li>
<a href=tag-$it.slug$.html>$it.name$</a> <a href='tag-$it.slug$.html'>$it.name$</a>
<span class=count>($it.count$)</span> <span class=count>($it.count$)</span>
$endfor$ $endfor$
</ul> </ul>