Commit 29fa37ef authored by Nicolas Lenz's avatar Nicolas Lenz ❄️
Browse files

Commentary

parent 39e8e5aa
Loading
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ buildArticles navbar inputs = do

    where extraMeta = Meta $ Map.fromList [("navbar", navbar)]

-- | Gets the previous and next neigbors for each article in the list. This only works if every pandocument has the link meta value set.
getNeighbors :: [Pandoc] -> [(Maybe MetaValue, Maybe MetaValue)]
getNeighbors articles = f <$> [0..(length articles - 1)] where
    -- Index + 1 is previous as the newest is first in the list
@@ -84,7 +85,8 @@ getNeighbors articles = f <$> [0..(length articles - 1)] where
getLink :: Pandoc -> Maybe MetaValue
getLink (Pandoc meta _) = lookupMeta "link" meta


-- TODO replace with library function
-- | Safely retrieve an item from a list, returning Nothing on failure.
safeIndex :: [a] -> Int -> Maybe a
safeIndex [] _ = Nothing
safeIndex _ n | n < 0 = Nothing