format t format = fromString $ formatTime defaultTimeLocale format $ utcToLocalTime (hoursToTimeZone 8) t
myGroup :: (Eq a, Ord a) => [(a, b)] -> [(a, [b])]
-myGroup = map (\l -> (fst . head $ l, map snd l)) . groupBy ((==) `on` fst)
+myGroup = map (\l -> (fst . head $ l, map snd l)) . groupBy ((==) `on` fst) . sortBy (comparing fst)
stampsToEntryList :: [BlogEntry] -> EntryList
-stampsToEntryList stamps = map (\(a,b) -> (a, reverse $ map (\(c,d) -> (c, map (\(x, y) -> ("0" `append` (fromString . show) x, y)) $ zip [1..] d)) b)) $
+stampsToEntryList stamps = reverse $ map (\(a,b) -> (a, reverse $ map (\(c,d) -> (c, map (\(x, y) -> ("0" `append` (fromString . show) x, y)) $ zip [1..] d)) b)) $
map (\(a, b) -> (a, myGroup b)) $
map (\(a, b) -> (a, concat b)) $ myGroup $
foldl (\c -> \v ->
month) entries) months) el
entryListToIndex :: EntryList -> Text
-entryListToIndex el = unorderedList Nothing $ map (\(year, monthList) -> unorderedList (Just year) $ map (\(month, entryList) -> unorderedList (Just month) $ map (\x -> "<a href=\"" <> year <> "/" <> month <> "/" <> ((slugify . title . snd) x) <> ".html\">" <> (title . snd) x <> "</a>") entryList) monthList) el
+entryListToIndex el = unorderedList Nothing $ map (\(year, monthList) -> unorderedList (Just year) $ map (\(month, entryList) -> unorderedList (Just month) $ map (\x -> "<a href=\"" <> year <> "/" <> month <> "/" <> ((urlify . title . snd) x) <> ".html\">" <> (title . snd) x <> "</a>") entryList) monthList) el
i2t :: Integer -> Text
i2t = (fromString . show)
slugify = toLower. replace " " "-"
+urlify = slugify . replace "?" ""
timeStampToDateString = fromString . formatTime defaultTimeLocale "%d %B %Y" . utcToLocalTime (hoursToTimeZone 8)
"build",
format (postDate entry) "%Y",
format (postDate entry) "%B",
- slugify (title entry) `append` ".html"]) $ unpack $ entryToMarkup entry entryTemplate
+ urlify (title entry) `append` ".html"]) $ unpack $ entryToMarkup entry entryTemplate
exportIndex :: EntryList -> IO()
exportIndex entryList = do