From bc759bbaf953f45a1bb537d753e1c734480074a5 Mon Sep 17 00:00:00 2001 From: Amy Gale Ruth Bowersox Date: Sun, 11 Aug 2024 22:45:11 -0600 Subject: [PATCH] omit unpublished pages from backlinks --- src/dragonglass/template.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dragonglass/template.py b/src/dragonglass/template.py index c84ae97..e822908 100644 --- a/src/dragonglass/template.py +++ b/src/dragonglass/template.py @@ -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]