slug generation improvements
This commit is contained in:
parent
32edbb1816
commit
0438ee590f
2 changed files with 9 additions and 5 deletions
|
@ -25,10 +25,14 @@ getOptionsWith hdr mkDef descrs = do
|
|||
exitFailure
|
||||
|
||||
makeSlug :: Text -> Text
|
||||
makeSlug name = Text.map toSlugChar name where
|
||||
toSlugChar c
|
||||
| isAlphaNum c && isAscii c || c == '-' = toLower c
|
||||
| otherwise = '_'
|
||||
makeSlug = Text.intercalate "-" . filter (not . Text.null) . chunks where
|
||||
chunks txt =
|
||||
if Text.null txt then [] else
|
||||
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]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<ul class=tag-list>
|
||||
$for(all-tags)$
|
||||
<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>
|
||||
$endfor$
|
||||
</ul>
|
||||
|
|
Loading…
Add table
Reference in a new issue