@@ -31,7 +31,6 @@ def get_route(path: str):
3131
3232
3333def more_posts (current_post : dict ) -> rx .Component :
34-
3534 posts = []
3635 app_items = list (gallery_apps_data_copy .items ())
3736 current_index = next (
@@ -49,8 +48,8 @@ def more_posts(current_post: dict) -> rx.Component:
4948 selected_posts = app_items [- 3 :]
5049 else :
5150 # Create a list of all posts except the current one
52- other_posts = app_items [:current_index ] + app_items [current_index + 1 :]
53-
51+ other_posts = app_items [:current_index ] + app_items [current_index + 1 :]
52+
5453 if len (other_posts ) <= 3 :
5554 # If there are 3 or fewer other posts, show all of them
5655 selected_posts = other_posts
@@ -63,9 +62,9 @@ def more_posts(current_post: dict) -> rx.Component:
6362 else :
6463 # For all other cases, show one before and two after (or two before and one after if we're near the end)
6564 if current_index < len (app_items ) - 2 :
66- selected_posts = other_posts [current_index - 1 : current_index + 2 ]
65+ selected_posts = other_posts [current_index - 1 : current_index + 2 ]
6766 else :
68- selected_posts = other_posts [current_index - 2 : current_index + 1 ]
67+ selected_posts = other_posts [current_index - 2 : current_index + 1 ]
6968
7069 for path , document in selected_posts :
7170 meta = document .metadata
@@ -131,14 +130,20 @@ def page(document) -> rx.Component:
131130 class_name = "flex flex-col gap-3 p-8" ,
132131 ),
133132 rx .box (
134- rx .link (
135- button_with_icon (
136- "View Demo" ,
137- icon = "new_tab" ,
138- class_name = "!w-full flex-row-reverse gap-2" ,
139- ),
140- is_external = True ,
141- href = meta ["demo" ],
133+ * (
134+ [
135+ rx .link (
136+ button_with_icon (
137+ "View Demo" ,
138+ icon = "new_tab" ,
139+ class_name = "!w-full flex-row-reverse gap-2" ,
140+ ),
141+ is_external = True ,
142+ href = meta ["demo" ],
143+ )
144+ ]
145+ if meta .get ("demo" )
146+ else []
142147 ),
143148 rx .link (
144149 button ("View Code" , variant = "muted" , class_name = "!w-full" ),
@@ -192,9 +197,9 @@ def page(document) -> rx.Component:
192197 title = document .metadata ["title" ],
193198 description = document .metadata ["description" ],
194199 image = document .metadata ["image" ],
195- demo = document .metadata ["demo" ],
200+ demo = document .metadata ["demo" ] if "demo" in document . metadata else None ,
196201 meta = document .metadata ["meta" ],
197202 )(lambda doc = document : page (doc ))
198203
199204 # Add the route to the list of routes.
200- gallery_apps_routes .append (comp )
205+ gallery_apps_routes .append (comp )
0 commit comments