omit unpublished pages from backlinks

This commit is contained in:
Amy G. Bowersox 2024-08-11 22:45:11 -06:00
parent fdcdb6a766
commit bc759bbaf9

View File

@ -89,8 +89,8 @@ def template_vars(node: SourceNode, ctxt: Context) -> dict[str, Any]:
tvars["dragonglass_version"] = __version__
tvars["python_version"] = f"{sys.version_info[0]}.{sys.version_info[1]}.{sys.version_info[2]}"
# Compute backlinks for this node.
backlinks = sorted(node.backlinks, key=lambda n: n.page_title)
# Compute backlinks for this node. Don't include nodes that aren't published.
backlinks = sorted([n for n in node.backlinks if n.publish], key=lambda n: n.page_title)
tvars['backlinks'] = [{'title': n.page_title,
'link': n.link_target(ctxt.url_prefix, node if ctxt.relative_links else None)}
for n in backlinks]