fix the page naming lambda, add demo

closes #18
This commit is contained in:
Mirek Kratochvil 2023-10-20 09:25:23 +02:00
parent b63146f517
commit cabb492b34
2 changed files with 5 additions and 3 deletions

View file

@ -190,8 +190,9 @@ pageName' :: Site (FilePath -> String)
pageName' = do pageName' = do
ps <- use pages ps <- use pages
pure $ \mnt' -> pure $ \mnt' ->
just ("template looks for undefined page name : " ++ mnt') just ("lookup for undefined page name : " ++ mnt')
$ ps M.!? unAbsolute mnt' >>= (^? pageMeta . key "template" . _String . to T.unpack) $ ps M.!? unAbsolute mnt'
>>= (^? pageMeta . key "name" . _String . to T.unpack)
-- | Like `Mu.substitute` but writes (and eventually should throw) stuff on errors -- | Like `Mu.substitute` but writes (and eventually should throw) stuff on errors
checkedSubstitute :: Mu.Template -> MT.Value -> IO T.Text checkedSubstitute :: Mu.Template -> MT.Value -> IO T.Text

View file

@ -1,9 +1,10 @@
<header> <header>
Navigation: Navigation:
<ul> <ul>
<li><a href="{{#pageLink}}/{{/pageLink}}">{{#pageName}}/{{/pageName}}</a></li>
<li><a href="{{#pageLink}}/tag{{/pageLink}}">Tags</a></li> <li><a href="{{#pageLink}}/tag{{/pageLink}}">Tags</a></li>
<li><a href="{{#pageLink}}/list{{/pageLink}}">List</a></li> <li><a href="{{#pageLink}}/list{{/pageLink}}">List</a></li>
<li><a href="{{#pageLink}}/search{{/pageLink}}">Search</a></li> <li><a href="{{#pageLink}}/search{{/pageLink}}">{{#pageName}}/search{{/pageName}}</a></li>
</ul> </ul>
{{?htags}} {{?htags}}