22
33from pcweb .constants import REFLEX_DOMAIN , REFLEX_DOMAIN_URL , TWITTER_CREATOR
44
5+ TITLE = "The unified platform to build and scale enterprise apps."
56ONE_LINE_DESCRIPTION = "Build with AI, iterate in Python, deploy to any cloud. The unified platform to build and scale enterprise apps."
67
7- meta_tags = [
8- # HTML Meta Tags
9- {"name" : "application-name" , "content" : "Reflex" },
10- {
11- "name" : "keywords" ,
12- "content" : "reflex, python, web apps, framework, open source, frontend, backend, full stack" ,
13- },
14- {
15- "name" : "description" ,
16- "content" : ONE_LINE_DESCRIPTION ,
17- },
18- # Facebook Meta Tags
19- {"property" : "og:url" , "content" : REFLEX_DOMAIN_URL },
20- {"property" : "og:type" , "content" : "website" },
21- {"property" : "og:title" , "content" : "Reflex · Build with AI, Deploy with Python" },
22- {
23- "property" : "og:description" ,
24- "content" : ONE_LINE_DESCRIPTION ,
25- },
26- {"property" : "og:image" , "content" : "/previews/index_preview.webp" },
27- # Twitter Meta Tags
28- {"name" : "twitter:card" , "content" : "summary_large_image" },
29- {"property" : "twitter:domain" , "content" : REFLEX_DOMAIN },
30- {"property" : "twitter:url" , "content" : REFLEX_DOMAIN_URL },
31- {"name" : "twitter:title" , "content" : "Reflex · Build with AI, Deploy with Python" },
32- {
33- "name" : "twitter:description" ,
34- "content" : ONE_LINE_DESCRIPTION ,
35- },
36- {"name" : "twitter:image" , "content" : "/previews/index_preview.webp" },
37- {"name" : "twitter:creator" , "content" : TWITTER_CREATOR },
38- ]
39-
40- hosting_meta_tags = [
41- # HTML Meta Tags
42- {"name" : "application-name" , "content" : "Reflex" },
43- {
44- "name" : "keywords" ,
45- "content" : "reflex, python, web apps, framework, open source, frontend, backend, full stack" ,
46- },
47- {
48- "name" : "description" ,
49- "content" : ONE_LINE_DESCRIPTION ,
50- },
51- # Facebook Meta Tags
52- {"property" : "og:url" , "content" : REFLEX_DOMAIN_URL },
53- {"property" : "og:type" , "content" : "website" },
54- {"property" : "og:title" , "content" : "Reflex · Build with AI, Deploy with Python" },
55- {
56- "property" : "og:description" ,
57- "content" : ONE_LINE_DESCRIPTION ,
58- },
59- {"property" : "og:image" , "content" : "/previews/hosting_preview.webp" },
60- # Twitter Meta Tags
61- {"name" : "twitter:card" , "content" : "summary_large_image" },
62- {"property" : "twitter:domain" , "content" : REFLEX_DOMAIN },
63- {"property" : "twitter:url" , "content" : REFLEX_DOMAIN_URL },
64- {"name" : "twitter:title" , "content" : "Reflex · Build with AI, Deploy with Python" },
65- {
66- "name" : "twitter:description" ,
67- "content" : ONE_LINE_DESCRIPTION ,
68- },
69- {"name" : "twitter:image" , "content" : "/previews/hosting_preview.webp" },
70- {"name" : "twitter:creator" , "content" : TWITTER_CREATOR },
71- ]
8+ # Common constants
9+ APPLICATION_NAME = "Reflex"
10+ TWITTER_CARD_TYPE = "summary_large_image"
11+ OG_TYPE = "website"
12+
13+
14+ def _build_meta_tags (
15+ title : str ,
16+ description : str ,
17+ image : str ,
18+ url : str = REFLEX_DOMAIN_URL ,
19+ ) -> list [dict [str , str ]]:
20+ """Build a list of meta tags with the given parameters.
21+
22+ Args:
23+ title: The page title.
24+ description: The page description.
25+ image: The image path for social media previews.
26+ url: The page URL (defaults to REFLEX_DOMAIN_URL).
27+
28+ Returns:
29+ A list of meta tag dictionaries.
30+ """
31+ return [
32+ # HTML Meta Tags
33+ {"name" : "application-name" , "content" : APPLICATION_NAME },
34+ {"name" : "description" , "content" : description },
35+ # Facebook Meta Tags
36+ {"property" : "og:url" , "content" : url },
37+ {"property" : "og:type" , "content" : OG_TYPE },
38+ {"property" : "og:title" , "content" : title },
39+ {"property" : "og:description" , "content" : description },
40+ {"property" : "og:image" , "content" : image },
41+ # Twitter Meta Tags
42+ {"name" : "twitter:card" , "content" : TWITTER_CARD_TYPE },
43+ {"property" : "twitter:domain" , "content" : REFLEX_DOMAIN },
44+ {"property" : "twitter:url" , "content" : url },
45+ {"name" : "twitter:title" , "content" : title },
46+ {"name" : "twitter:description" , "content" : description },
47+ {"name" : "twitter:image" , "content" : image },
48+ {"name" : "twitter:creator" , "content" : TWITTER_CREATOR },
49+ ]
50+
51+
52+ meta_tags = _build_meta_tags (
53+ title = TITLE ,
54+ description = ONE_LINE_DESCRIPTION ,
55+ image = "/previews/index_preview.webp" ,
56+ )
57+
58+ hosting_meta_tags = _build_meta_tags (
59+ title = TITLE ,
60+ description = ONE_LINE_DESCRIPTION ,
61+ image = "/previews/hosting_preview.webp" ,
62+ )
7263
7364
7465def favicons_links () -> list [rx .Component ]:
@@ -90,42 +81,27 @@ def favicons_links() -> list[rx.Component]:
9081def create_meta_tags (
9182 title : str , description : str , image : str , url : str | None = None
9283) -> list [rx .Component ]:
84+ """Create meta tags for a page.
85+
86+ Args:
87+ title: The page title.
88+ description: The page description.
89+ image: The image path for social media previews.
90+ url: The page URL (optional, defaults to REFLEX_DOMAIN_URL).
91+
92+ Returns:
93+ A list of meta tag dictionaries.
94+ """
9395 page_url = url if url else REFLEX_DOMAIN_URL
9496
9597 if image and not image .startswith (("http://" , "https://" )):
9698 image_url = f"https://reflex.dev{ '' if image .startswith ('/' ) else '/' } { image } "
9799 else :
98100 image_url = image
99101
100- return [
101- # HTML Meta Tags
102- {"name" : "application-name" , "content" : "Reflex" },
103- {
104- "name" : "keywords" ,
105- "content" : "reflex, python, web apps, framework, open source, frontend, backend, full stack" ,
106- },
107- {
108- "name" : "description" ,
109- "content" : description ,
110- },
111- # Facebook Meta Tags
112- {"property" : "og:url" , "content" : page_url },
113- {"property" : "og:type" , "content" : "website" },
114- {"property" : "og:title" , "content" : title },
115- {
116- "property" : "og:description" ,
117- "content" : description ,
118- },
119- {"property" : "og:image" , "content" : image_url },
120- # Twitter Meta Tags
121- {"name" : "twitter:card" , "content" : "summary_large_image" },
122- {"property" : "twitter:domain" , "content" : REFLEX_DOMAIN },
123- {"property" : "twitter:url" , "content" : page_url },
124- {"name" : "twitter:title" , "content" : title },
125- {
126- "name" : "twitter:description" ,
127- "content" : description ,
128- },
129- {"name" : "twitter:image" , "content" : image_url },
130- {"name" : "twitter:creator" , "content" : TWITTER_CREATOR },
131- ]
102+ return _build_meta_tags (
103+ title = title ,
104+ description = description ,
105+ image = image_url ,
106+ url = page_url ,
107+ )
0 commit comments