Skip to content

Commit b349f72

Browse files
pickleloElijahAhianyo
authored andcommitted
Assets section
1 parent 3cc8feb commit b349f72

File tree

7 files changed

+59
-55
lines changed

7 files changed

+59
-55
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import reflex as rx
44

55
# Assets
66

7-
Static files such as images and stylesheets can be placed in `"assets/"` folder of the project. These files can be referenced within your app.
7+
Static files such as images and stylesheets can be placed in `assets/` folder of the project. These files can be referenced within your app.
88

99
```md alert
1010
# Assets are copied during the build process.
@@ -15,7 +15,7 @@ when running in production mode. The `assets/` folder should only be used for st
1515

1616
## Referencing Assets
1717

18-
To reference an image in the `"assets/"` simply pass the relative path as a prop.
18+
To reference an image in the `assets/` simply pass the relative path as a prop.
1919

2020
For example, you can store your logo in your assets folder:
2121

@@ -38,4 +38,4 @@ rx.image(src="/Reflex.svg", width="5em")
3838

3939
The favicon is the small icon that appears in the browser tab.
4040

41-
You can add a `"favicon.ico"` file to the `"assets/"` folder to change the favicon.
41+
You can add a `favicon.ico` file to the `assets/` folder to change the favicon.

docs/pages/dynamic_routing.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ and optional catch-all routes, each with detailed examples.
1212

1313
## Regular Dynamic Routes
1414

15-
Regular dynamic routes in Reflex allow you to match specific segments in a URL dynamically. A regular dynamic route is defined by sqaure brackets in a route string / url pattern. For example `/users/[id]` or `/products/[category]`. These dynamic route arguments can be accesed by as a state var. For the examples above they would be `rx.State.id` and `rx.State.category` respectively.
15+
Regular dynamic routes in Reflex allow you to match specific segments in a URL dynamically. A regular dynamic route is defined by sqaure brackets in a route string / url pattern. For example `/users/[id]` or `/products/[category]`. These dynamic route arguments can be accesed through a state var. For the examples above they would be `rx.State.id` and `rx.State.category` respectively.
1616

1717
```md alert info
1818
# Why is the state var accessed as `rx.State.id`?
@@ -37,7 +37,10 @@ The [pid] part in the route is a dynamic segment, meaning it can match any value
3737
If a user navigates to `/post/5`, `State.post_id` will return `5`, and the page will display `5` as the heading. If the URL is `/post/xyz`, it will display `xyz`. If the URL is `/post/` without any additional parameter, it will display `""`.
3838

3939

40-
### Using `app.add_page` Method
40+
### Adding Dynamic Routes
41+
42+
Adding dynamic routes uses the `add_page` method like any other page. The only difference is that the route string contains dynamic segments enclosed in square brackets.
43+
4144

4245
If you are using the `app.add_page` method to define pages, it is necessary to add the dynamic routes first, especially if they use the same function as a non dynamic route.
4346

docs/pages/metadata.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

docs/pages/overview.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
```python exec
22
import reflex as rx
33
from pcweb import constants, styles
4+
from pcweb.pages import docs
45
from pcweb.pages.docs import api_reference, library
56
```
67

@@ -152,6 +153,52 @@ app = rx.App()
152153

153154
This component will be available at `/nested/page`.
154155

156+
## Page Metadata
157+
158+
```python exec
159+
160+
import reflex as rx
161+
162+
meta_data = (
163+
"""
164+
@rx.page(
165+
title='My Beautiful App',
166+
description='A beautiful app built with Reflex',
167+
image='/splash.png',
168+
meta=meta,
169+
)
170+
def index():
171+
return rx.text('A Beautiful App')
172+
173+
@rx.page(title='About Page')
174+
def about():
175+
return rx.text('About Page')
176+
177+
178+
meta = [
179+
{'name': 'theme_color', 'content': '#FFFFFF'},
180+
{'char_set': 'UTF-8'},
181+
{'property': 'og:url', 'content': 'url'},
182+
]
183+
184+
app = rx.App()
185+
"""
186+
187+
)
188+
189+
```
190+
191+
You can add page metadata such as:
192+
193+
- The title to be shown in the browser tab
194+
- The description as shown in search results
195+
- The preview image to be shown when the page is shared on social media
196+
- Any additional metadata
197+
198+
```python
199+
{meta_data}
200+
```
201+
155202
## Getting the Current Page
156203

157204
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.

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def get_sidebar_items_frontend():
5959
children=[
6060
pages.overview,
6161
pages.dynamic_routing,
62-
pages.metadata,
6362
],
6463
),
6564
create_item(
@@ -76,7 +75,7 @@ def get_sidebar_items_frontend():
7675
create_item(
7776
"Assets",
7877
children=[
79-
assets.referencing_assets,
78+
assets.overview,
8079
assets.upload_and_download_files,
8180
],
8281
),

pcweb/pcweb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@
138138
# Redirect any removed pages to their new home.
139139
("/docs/components/style-props", "/docs/components/props"),
140140
("/docs/components/conditional-props", "/docs/components/conditional-rendering"),
141-
("/docs/pages/routes", "/docs/pages/overview")
142-
141+
("/docs/pages/routes", "/docs/pages/overview"),
142+
("/docs/assets/referencing_assets", "/docs/assets/overview"),
143143
]
144144

145145
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", "/docs/pages"]
12+
WHITELISTED_PAGES = []
1313

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

0 commit comments

Comments
 (0)