Generating links for a table of contents using code from pollen-tfl
#67
Closed
opened 4 years ago by matiasz
·
4 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
I’m trying to use the code below — from
toc.html.pm
in the pollen-tfl repository — to create page links in a table of contents.The code is successfully creating links for each file in
index.ptree
, in the sense that thehref
s are correct: clicking the link brings you to the correct page. But the displayed text of each link is in the format “introduction.html” instead of simply “introduction”.I’d appreciate any guidance on how to set the text of each link to be the
title
property from each page’smetas
.I believe that’s because of the
dev-mode?
check in thenode->link
function. Fetching all the titles out of the pages can be slow, so it is meant to save some time while you’re in, you know, dev mode.Thank you, Matthew. When I’m in dev mode, it successfully loads
node-string
as thelink-name
. But when I’m not in dev mode, it attempts(select-from-metas 'title node)
and fails with this error:Do I need to add a function call to make other pages’
metas
available in the file with this TOC-building code? I haven’t found a way to do this; therequire
statement mentioned in “12.3.1.5 Retrieving metas” seems to apply only to.rkt
files and not.html.pm
files, which is where I’m trying to getmetas
from.I resolved the problem by adding a
get-metas
call to thenode->link
function:select-from-metas
was trying to usenode
as themetas
and was thus returning#f
instead of the node’s actual title. I don’t know that this method is the best, but it works.That’s a little strange —
select-from-metas
can accept a node name, so(get-metas node)
should be the same asnode
in that position. In researching this issue, I did find a small bug inpollen
itself that was causing a difficulty withpollen-tfl
. I pushed a fix for that. But I don’t know if it’s related.