Skip to content

Commit 2fe1a44

Browse files
authored
Updates to support docs frontend path (#6359)
* Updates to support docs frontend path * just set /docs
1 parent a4ebb0b commit 2fe1a44

29 files changed

Lines changed: 217 additions & 204 deletions

File tree

docs/api-reference/event_triggers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def unmount_example():
266266
rx.text(UnmountState.status),
267267
rx.link(
268268
rx.button("Navigate Away (Triggers Unmount)"),
269-
href="/docs",
269+
href="/",
270270
),
271271
on_mount=UnmountState.initialize_resource,
272272
on_unmount=UnmountState.on_unmount,

docs/app/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ Markdown docs live in the parent `docs/` directory (one level above `app/`). Edi
2424

2525
By default, the dev server compiles **all** pages, which can be slow. To speed things up, you can whitelist only the pages you're working on so only those get compiled.
2626

27-
Edit `reflex_docs/whitelist.py` and add paths to the `WHITELISTED_PAGES` list:
27+
Edit `reflex_docs/whitelist.py` and add paths to the `WHITELISTED_PAGES` list. Paths are **app routes** (relative to `frontend_path`, which defaults to `/docs` in `rxconfig.py`). Do not repeat the `/docs` mount segment in the whitelist, or nothing will match.
2828

2929
```python
3030
WHITELISTED_PAGES = [
31-
"/docs/getting-started/introduction",
32-
"/docs/components/props",
31+
"/getting-started/introduction",
32+
"/components/props",
3333
]
3434
```
3535

3636
**Rules:**
3737
- Each path must start with a forward slash `/`.
38-
- Do **not** include a trailing slash (e.g. `/docs/components/props`, not `/docs/components/props/`).
38+
- Do **not** include a trailing slash (e.g. `/getting-started/introduction`, not `/getting-started/introduction/`).
3939
- An empty list (`[]`) builds all pages (the default).
40-
- Paths are prefix-matched, so `"/docs/components"` will include all pages under that section.
40+
- Paths are prefix-matched, so `"/components"` will include all pages under that section.
4141

4242
After editing the whitelist, restart the dev server for changes to take effect.

docs/app/reflex_docs/components/docpage/navbar/buttons/sidebar.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,18 @@ def drawer_item(text: str, url: str, active_str: str = "") -> rx.Component:
5555
url += "/"
5656
active = router_path.contains(active_str)
5757
if active_str == "docs":
58+
is_docs_home = (router_path == "/") | (router_path == "/index")
5859
active = rx.cond(
59-
router_path.contains("hosting")
60-
| router_path.contains("library")
61-
| router_path.contains("gallery"),
60+
is_docs_home,
6261
False,
63-
active,
62+
~router_path.contains("hosting")
63+
& ~router_path.contains("library")
64+
& ~router_path.contains("gallery")
65+
& ~router_path.contains("ai-builder"),
6466
)
6567
if active_str == "":
6668
active = False
67-
return rx.link(
69+
return rx.el.elements.a(
6870
text,
6971
href=url,
7072
underline="none",

docs/app/reflex_docs/pages/docs/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,14 @@ def doc_title_from_path(doc: str) -> str:
152152

153153

154154
def doc_route_from_path(doc: str) -> str:
155-
"""Compute the URL route from a doc path."""
155+
"""Compute the URL route from a doc path.
156+
157+
Virtual paths are rooted at ``docs/`` (the content directory). The site is
158+
already served under ``frontend_path`` (e.g. ``/docs``), so the public path
159+
must not repeat that segment (``/docs/docs/...``).
160+
"""
161+
doc = doc.replace("\\", "/")
162+
doc = doc.removeprefix("docs/")
156163
route = rx.utils.format.to_kebab_case(f"/{doc.replace('.md', '/')}")
157164
if route.endswith("/index/"):
158165
route = route[:-7] + "/"

docs/app/reflex_docs/pages/docs/api_reference/plugins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from reflex_docs.templates.docpage import docpage
66

77

8-
@docpage("/docs/api-reference/plugins/")
8+
@docpage("/api-reference/plugins/")
99
def plugins():
1010
"""Plugins API reference page."""
1111
with open("docs/api-reference/plugins.md", encoding="utf-8") as f:

docs/app/reflex_docs/pages/docs/api_reference/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from reflex_docs.templates.docpage import docpage
66

77

8-
@docpage("/docs/api-reference/utils/")
8+
@docpage("/api-reference/utils/")
99
def utils():
1010
"""Utils API reference page."""
1111
with open("docs/api-reference/utils.md", encoding="utf-8") as f:

docs/app/reflex_docs/pages/docs/apiref.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
name = module.__name__.lower()
4040
docs = generate_docs(name, module, extra_fields=extra_fields)
4141
title = name.replace("_", " ").title()
42-
page_data = docpage(f"/docs/api-reference/{name}/", title)(docs)
42+
page_data = docpage(f"/api-reference/{name}/", title)(docs)
4343
page_data.title = page_data.title.split("·")[0].strip()
4444
pages.append(page_data)
4545

docs/app/reflex_docs/pages/docs/cloud_cliref.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,6 @@ def generate_docs(source: str):
352352
for module_name, module_value in modules.items():
353353
docs = generate_docs(module_value)
354354
title = module_name.replace("_", " ").title()
355-
page_data = docpage(f"/docs/hosting/cli/{module_name}/", title)(docs)
355+
page_data = docpage(f"/hosting/cli/{module_name}/", title)(docs)
356356
page_data.title = page_data.title.split("·")[0].strip()
357357
pages.append(page_data)

docs/app/reflex_docs/pages/docs/custom_components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def create_pagination():
403403
)
404404

405405

406-
@docpage(right_sidebar=False)
406+
@docpage(set_path="/custom-components/", right_sidebar=False)
407407
def custom_components() -> rx.Component:
408408
return rx.box(
409409
rx.box(

docs/app/reflex_docs/pages/docs/enterprise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
@docpage(
7-
set_path="/docs/enterprise/overview",
7+
set_path="/enterprise/overview",
88
t="Overview | Enterprise",
99
)
1010
def overview():

0 commit comments

Comments
 (0)