Skip to content

Commit 4c21028

Browse files
adhami3310masenf
andauthored
do not change title to be titled (#1715)
* do not change title to be titled * use same slug calculation for building links and routes in gallery apps --------- Co-authored-by: Masen Furer <m_github@0x26.net>
1 parent 5a3cd26 commit 4c21028

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

pcweb/components/code_card.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import re
2+
13
import reflex as rx
24
import reflex_ui as ui
35
from reflex.experimental.client_state import ClientStateVar
@@ -107,6 +109,7 @@ def code_card(app: dict) -> rx.Component:
107109

108110

109111
def gallery_app_card(app: dict[str, str]) -> rx.Component:
112+
slug = re.sub(r"[\s_]+", "-", app["title"]).lower()
110113
return rx.flex(
111114
rx.box(
112115
rx.link(
@@ -116,7 +119,7 @@ def gallery_app_card(app: dict[str, str]) -> rx.Component:
116119
alt="Image preview for app: " + app["title"],
117120
class_name="size-full duration-150 object-cover hover:scale-105 transition-transform ease-out",
118121
),
119-
href=f"/docs/getting-started/open-source-templates/{app['title'].replace(' ', '-').lower()}",
122+
href=f"/docs/getting-started/open-source-templates/{slug}",
120123
),
121124
class_name="relative border-slate-5 border-b border-solid w-full overflow-hidden h-[180px]",
122125
),

pcweb/pages/gallery/apps.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ def load_all_gallery_apps():
5050
paths = flexdown.utils.get_flexdown_files(folder)
5151
for path in sorted(paths, reverse=True):
5252
document = flexdown.Document.from_file(path) # This has metadata
53-
document.metadata["title"] = (
54-
document.metadata.get("title", "Untitled").replace("_", " ").title()
55-
)
53+
document.metadata["title"] = document.metadata.get("title", "Untitled")
5654
clean_path = str(path).replace(".md", "/")
5755
gallery_apps[(clean_path, folder)] = document
5856
return gallery_apps

0 commit comments

Comments
 (0)