Skip to content

Commit 9a5c4d3

Browse files
authored
Fix wrong Blog and FAQ links in docs footer (#6731)
* Fix wrong Blog and FAQ links in docs footer * update * and this
1 parent 3b97060 commit 9a5c4d3

2 files changed

Lines changed: 44 additions & 8 deletions

File tree

docs/app/reflex_docs/templates/docpage/docpage.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,24 @@ def handle_submit(self, form_data: dict):
8989
pass
9090

9191

92-
def footer_link(text: str, href: str):
93-
return rx.link(
94-
text,
95-
class_name="font-small text-secondary-9 hover:!text-secondary-11 transition-color",
96-
href=href,
97-
underline="none",
92+
def footer_link(text: str, href: str, *, root_site: bool = False) -> rx.Component:
93+
"""Create a footer link, optionally bypassing the docs router basename.
94+
95+
Args:
96+
text: The visible link label.
97+
href: The link destination.
98+
root_site: Whether the destination is outside the docs router basename.
99+
100+
Returns:
101+
The styled footer link.
102+
"""
103+
class_name = (
104+
"font-small text-secondary-9 hover:!text-secondary-11 "
105+
"transition-color no-underline"
98106
)
107+
if root_site:
108+
return rx.el.elements.a(text, href=href, class_name=class_name)
109+
return rx.link(text, href=href, class_name=class_name, underline="none")
99110

100111

101112
def footer_link_flex(heading: str, links):
@@ -360,7 +371,7 @@ def docpage_footer(path: rx.Var[str]) -> rx.Component:
360371
"Links",
361372
[
362373
footer_link("Home", "/"),
363-
footer_link("Blog", "/blog"),
374+
footer_link("Blog", "/blog/", root_site=True),
364375
footer_link("Changelog", "/changelog/"),
365376
],
366377
),
@@ -376,7 +387,7 @@ def docpage_footer(path: rx.Var[str]) -> rx.Component:
376387
footer_link_flex(
377388
"Resources",
378389
[
379-
footer_link("FAQ", "/faq/"),
390+
footer_link("FAQ", "/faq/", root_site=True),
380391
footer_link("Roadmap", ROADMAP_URL),
381392
footer_link("Forum", FORUM_URL),
382393
],

docs/app/tests/test_routes.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from collections import Counter
44

55
import pytest
6+
import reflex as rx
67

78

89
@pytest.fixture
@@ -62,3 +63,27 @@ def test_docs_route_descriptions_fit_search_snippet_length(routes_fixture):
6263
}
6364

6465
assert overlong == {}
66+
67+
68+
@pytest.mark.parametrize(
69+
("label", "href"),
70+
[("Blog", "/blog/"), ("FAQ", "/faq/")],
71+
)
72+
def test_docpage_footer_uses_root_site_anchors(label: str, href: str):
73+
"""Root-site footer links should not inherit the /docs router basename."""
74+
from reflex_docs.templates.docpage.docpage import docpage_footer
75+
76+
rendered = docpage_footer.__wrapped__(rx.Var.create("/test")).render()
77+
78+
def find_link(node: dict) -> dict | None:
79+
if any(child.get("contents") == f'"{label}"' for child in node["children"]):
80+
return node
81+
for child in node["children"]:
82+
if "children" in child and (link := find_link(child)) is not None:
83+
return link
84+
return None
85+
86+
link = find_link(rendered)
87+
assert link is not None
88+
assert link["name"] == '"a"'
89+
assert f'href:"{href}"' in link["props"]

0 commit comments

Comments
 (0)