Skip to content

Commit 3cc8feb

Browse files
pickleloElijahAhianyo
authored andcommitted
Update pages docs
1 parent fb16b4e commit 3cc8feb

File tree

5 files changed

+25
-27
lines changed

5 files changed

+25
-27
lines changed

docs/getting_started/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def tabs():
100100
),
101101
rx.tabs.content(
102102
rx.markdown(
103-
f"""Each page is a Python function that returns a Reflex component. You can define multiple pages and navigate between them, see the [Routing]({pages.routes.path}) section for more information.
103+
f"""Each page is a Python function that returns a Reflex component. You can define multiple pages and navigate between them, see the [pages]({pages.overview.path}) section for more information.
104104
105105
- Start with a single page and scale to 100s of pages.
106106
""",
Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ from pcweb.pages.docs import api_reference, library
66

77
# Pages
88

9-
Pages in Reflex allow you to define components for different URLs. This section covers creating pages, handling URL
10-
arguments, accessing query parameters, managing page metadata, and handling page load events.
9+
Pages map components to different URLs in your app. This section covers creating pages, handling URL arguments, accessing query parameters, managing page metadata, and handling page load events.
1110

1211
## Adding a Page
1312

@@ -70,7 +69,7 @@ You can directly import the module or import another module that imports the dec
7069

7170
### Links
7271

73-
Links are accessible elements used primarily for navigation. Use the `href` prop to specify the location for the link to navigate to.
72+
[Links]({library.typography.link.path}) are accessible elements used primarily for navigation. Use the `href` prop to specify the location for the link to navigate to.
7473

7574
```python demo
7675
rx.link("Reflex Home Page.", href="https://reflex.dev/")
@@ -79,10 +78,16 @@ rx.link("Reflex Home Page.", href="https://reflex.dev/")
7978
You can also provide local links to other pages in your project without writing the full url.
8079

8180
```python demo
82-
rx.link("Example", href="/docs/library",)
81+
rx.link("Example", href="/docs/library")
8382
```
8483

85-
Check out the docs [here]({library.typography.link.path}) to learn more.
84+
To open the link in a new tab, set the `is_external` prop to `True`.
85+
86+
```python demo
87+
rx.link("Open in new tab", href="https://reflex.dev/", is_external=True)
88+
```
89+
90+
Check out the [link docs]({library.typography.link.path}) to learn more.
8691

8792
```md video https://youtube.com/embed/ITOZkzjtjUA?start=4083&end=4423
8893
# Video: Link-based Navigation
@@ -147,13 +152,9 @@ app = rx.App()
147152

148153
This component will be available at `/nested/page`.
149154

150-
## Getting the Current Page Link
151-
152-
The `router.page.path` attribute allows you to obtain the path of the current page from the router data,
153-
for dynamic pages this will contain the slug rather than the actual value used to load the page.
155+
## Getting the Current Page
154156

155-
To get the actual URL displayed in the browser, use `router.page.raw_path`. This
156-
will contain all query parameters and dynamic path segments.
157+
You can access the current page from the `router` attribute in any state. See the [router docs]({docs.utility_methods.router_attributes.path}) for all available attributes.
157158

158159
```python
159160
class State(rx.State):
@@ -163,6 +164,13 @@ class State(rx.State):
163164
# ... Your logic here ...
164165
```
165166

167+
The `router.page.path` attribute allows you to obtain the path of the current page from the router data,
168+
for dynamic pages this will contain the slug rather than the actual value used to load the page.
169+
170+
To get the actual URL displayed in the browser, use `router.page.raw_path`. This
171+
will contain all query parameters and dynamic path segments.
172+
173+
166174
In the above example, `current_page_route` will contain the route pattern (e.g., `/posts/[id]`), while `current_page_url`
167175
will contain the actual URL (e.g., `http://example.com/posts/123`).
168176

@@ -178,15 +186,3 @@ class State(rx.State):
178186
```
179187

180188
In this example, running on `localhost` should display `http://localhost:3000/user/hey/posts/3/`
181-
182-
## Getting Client IP
183-
184-
You can use the `router.session.client_ip` attribute to obtain the IP address of the client associated
185-
with the current state.
186-
187-
```python
188-
class State(rx.State):
189-
def some_method(self):
190-
client_ip = self.router.session.client_ip
191-
# ... Your logic here ...
192-
```

pcweb/components/docpage/sidebar/sidebar_items/learn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def get_sidebar_items_frontend():
5757
create_item(
5858
"Pages",
5959
children=[
60-
pages.routes,
60+
pages.overview,
6161
pages.dynamic_routing,
6262
pages.metadata,
6363
],

pcweb/pcweb.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@
137137
("/gallery", "/templates"),
138138
# Redirect any removed pages to their new home.
139139
("/docs/components/style-props", "/docs/components/props"),
140-
("/docs/components/conditional-props", "/docs/components/conditional-rendering")
140+
("/docs/components/conditional-props", "/docs/components/conditional-rendering"),
141+
("/docs/pages/routes", "/docs/pages/overview")
142+
141143
]
142144

143145
for source, target in redirects:

pcweb/whitelist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# - Correct: WHITELISTED_PAGES = ["/docs/getting-started/introduction"]
1010
# - Incorrect: WHITELISTED_PAGES = ["/docs/getting-started/introduction/"]
1111

12-
WHITELISTED_PAGES = ["/docs/ui", "/docs/components", "/docs/getting-started"]
12+
WHITELISTED_PAGES = ["/docs/ui", "/docs/components", "/docs/getting-started", "/docs/pages"]
1313

1414
def _check_whitelisted_path(path):
1515
if len(WHITELISTED_PAGES) == 0:

0 commit comments

Comments
 (0)