Commit c21e8bb0 authored by Nicolas Lenz's avatar Nicolas Lenz

Make link meta root-relative.

parent 66f77ab3
Pipeline #295 passed with stage
in 2 minutes and 48 seconds
......@@ -21,7 +21,7 @@ putNavbar nebelhorn@Nebelhorn{..} = nebelhorn
f n@NavItem{..} = navItemToMeta navItemActiveOnArticles n
putNavbarPage pandoc@(Pandoc meta _) = addMeta "navbar" (MetaList $ f <$> nebelhornNavItems) pandoc where
f n@NavItem{..} = case lookupMeta "link" meta of
Just (MetaString link) -> navItemToMeta (unpack navItemLink == "/" <> link) n
Just (MetaString link) -> navItemToMeta (unpack navItemLink == link) n
_ -> navItemToMeta False n
navItemToMeta :: Bool -> NavItem -> MetaValue
navItemToMeta active NavItem{..} = MetaMap $ Map.fromList
......
......@@ -35,9 +35,9 @@ prependPath :: Path a Dir -> (Path Rel b, t) -> (Path a b, t)
prependPath basePath (path, x) = (basePath </> path, x)
-- | Puts a path into the meta values of a pandocument.
linkIntoMeta :: Path a File -> Pandoc -> Pandoc
linkIntoMeta :: Path Rel File -> Pandoc -> Pandoc
linkIntoMeta link (Pandoc (Meta metaMap) bs)
= Pandoc (Meta $ Map.insert "link" (MetaString $ toFilePath link) metaMap) bs
= Pandoc (Meta $ Map.insert "link" (MetaString $toFilePath $ [absdir|/|] </> link) metaMap) bs
-- | Reads all markdown files from a folder recursively,
-- returning their contents and paths (relative to the folder path).
......
......@@ -41,4 +41,6 @@ copyFolders sources sink = forM_ sources $ \source -> copyDirRecur source (sink
-- | Retrieves the link meta value as Path from a pandocument
getLink :: Pandoc -> Maybe (Path Rel File)
getLink (Pandoc meta _) = lookupMeta "link" meta >>= \(MetaString link) -> parseRelFile link
getLink (Pandoc meta _) = lookupMeta "link" meta
>>= (\(MetaString link) -> parseAbsFile link)
>>= stripProperPrefix [absdir|/|]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment