|
15 | 15 |
|
16 | 16 |
|
17 | 17 | from .articles.detail import article_detail_page |
18 | | -from .articles.list import article_public_list_page |
| 18 | +from .articles.list import article_public_list_page, article_public_list_component |
19 | 19 | from .articles.state import ArticlePublicState |
20 | 20 |
|
21 | 21 | from . import blog, contact, navigation, pages |
22 | 22 |
|
23 | | -class State(rx.State): |
24 | | - """The app state.""" |
25 | | - label = "Welcome to Reflex!" |
26 | | - |
27 | | - def handle_title_input_change(self, val): |
28 | | - self.label = val |
29 | | - |
30 | | - def did_click(self): |
31 | | - print("Hello world did click") |
32 | | - return rx.redirect(navigation.routes.ABOUT_US_ROUTE) |
33 | | - |
34 | 23 | def index() -> rx.Component: |
35 | | - # Welcome Page (Index) |
36 | | - my_user_obj = SessionState.authenticated_user_info |
37 | | - my_child = rx.vstack( |
38 | | - rx.heading(State.label, size="9"), |
39 | | - rx.text(my_user_obj.to_string()), |
40 | | - rx.text(my_user_obj.user.username), |
41 | | - rx.text( |
42 | | - "Get started by editing ", |
43 | | - rx.code(f"{config.app_name}/{config.app_name}.py"), |
44 | | - size="5", |
45 | | - ), |
46 | | - # rx.button("About us", on_click=State.did_click), |
47 | | - rx.link( |
48 | | - rx.button("About us"), |
49 | | - href=navigation.routes.ABOUT_US_ROUTE |
50 | | - ), |
51 | | - spacing="5", |
52 | | - justify="center", |
53 | | - align="center", |
54 | | - # text_align="center", |
55 | | - min_height="85vh", |
56 | | - id='my-child' |
| 24 | + return base_page( |
| 25 | + rx.cond(SessionState.is_authenticated, |
| 26 | + pages.dashboard_component(), |
| 27 | + pages.landing_component(), |
57 | 28 | ) |
58 | | - return base_page(my_child) |
| 29 | + ) |
59 | 30 |
|
60 | 31 |
|
61 | 32 |
|
62 | 33 |
|
63 | 34 | app = rx.App() |
64 | | -app.add_page(index) |
| 35 | +app.add_page(index, |
| 36 | + on_load=ArticlePublicState.load_posts |
| 37 | + ) |
65 | 38 | # reflex_local_auth pages |
66 | 39 | app.add_page( |
67 | 40 | my_login_page, |
|
0 commit comments