|
5 | 5 | <cfset isBlog = find("/blog", pathInfo)> |
6 | 6 | <cfset isApi = find("/api", pathInfo)> |
7 | 7 | <cfset pageTitle = "CFWheels - an open source CFML framework inspired by Ruby on Rails"> |
| 8 | +<cfset ogTitle = "CFWheels - an open source CFML framework inspired by Ruby on Rails"> |
| 9 | +<cfset metaDescription = "Build apps quickly with an organized, Ruby on Rails-inspired structure. Get up and running in no time!"> |
| 10 | +<cfset ogDescription = "Build apps quickly with an organized, Ruby on Rails-inspired structure. Get up and running in no time!"> |
8 | 11 |
|
9 | 12 | <cfif isBlog> |
10 | | - <cfset blogPath = listLast(pathInfo, "/")> |
11 | | - <cfif blogPath EQ "blog"> |
12 | | - <cfset pageTitle = "Blogs | CFWheels"> |
| 13 | + <cfset blogSlug = listLast(pathInfo, "/")> |
| 14 | + |
| 15 | + <!--- Fetch the blog post by slug ---> |
| 16 | + <cfset post = model("Blog").findOne(where="slug = '#blogSlug#'")> |
| 17 | + |
| 18 | + <cfif structKeyExists(post, "id")> |
| 19 | + <cfset pageTitle = post.title & " | CFWheels"> |
| 20 | + |
| 21 | + <!-- Generate meta description from content --> |
| 22 | + <cfset firstP = reFind("<p[^>]*>(.*?)</p>", post.content, 1, true)> |
| 23 | + <cfif arrayLen(firstP.pos) GT 1> |
| 24 | + <cfset metaDescription = mid(post.content, firstP.pos[2], firstP.len[2])> |
| 25 | + <cfelse> |
| 26 | + <cfset cleanContent = reReplace(post.content, "<[^>]*>", "", "all")> |
| 27 | + <cfset metaDescription = left(trim(cleanContent), 160)> |
| 28 | + </cfif> |
| 29 | + |
| 30 | + <cfset ogTitle = post.title> |
| 31 | + <cfset ogDescription = metaDescription> |
| 32 | +<!--- <cfset ogImage = ''> ---> |
13 | 33 | <cfelse> |
14 | | - <cfset blogSlug = listLast(pathInfo, "/")> |
15 | | - <cfset blogTitle = replace(blogSlug, "-", " ", "all")> |
16 | | - <cfset blogTitle = reReplace(blogTitle, "\b([a-z])", "\u\1", "all")> |
17 | | - <cfset pageTitle = blogTitle & " | CFWheels"> |
| 34 | + <!-- fallback --> |
| 35 | + <cfset pageTitle = "Blog | CFWheels"> |
| 36 | + <cfset metaDescription = "Explore our latest blogs on CFWheels."> |
| 37 | + <cfset ogTitle = pageTitle> |
| 38 | + <cfset ogDescription = metaDescription> |
18 | 39 | </cfif> |
19 | 40 | </cfif> |
20 | 41 |
|
| 42 | +<cfif isApi> |
| 43 | + <cfset apiPath = listLast(pathInfo, "/")> |
| 44 | + <cfset pageTitle = apiPath & " | CFWheels API "> |
| 45 | +</cfif> |
| 46 | + |
21 | 47 | <cfif isApi> |
22 | 48 | <cfset apiPath = listLast(pathInfo, "/")> |
23 | 49 | <cfset pageTitle = apiPath & " | CFWheels API "> |
|
39 | 65 | <link rel="icon" href="/images/favicon.ico" type="image/x-icon"> |
40 | 66 | <link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"> |
41 | 67 | <meta name="keywords" content="cfwheels,cfml,ruby,framework"> |
42 | | - <meta name="description" content="Build apps quickly with an organized, Ruby on Rails-inspired structure. Get up and running in no time!"> |
43 | | - <meta property="og:title" content="ColdFusion on Wheels"> |
| 68 | + <cfoutput> |
| 69 | + <meta name="description" content="#metaDescription#"> |
| 70 | + <meta property="og:title" content="#ogTitle#"> |
| 71 | + <meta property="og:description" content="#ogDescription#"> |
| 72 | + <cfif isDefined("ogImage")> |
| 73 | + <meta property="og:image" content="#ogImage#"> |
| 74 | + </cfif> |
| 75 | + </cfoutput> |
44 | 76 | <meta property="og:description" content="Build apps quickly with an organized, Ruby on Rails-inspired structure. Get up and running in no time!"> |
45 | 77 | <meta property="og:url" content="https://wheels.dev/"> |
46 | 78 | <meta property="og:site_name" content="CFWheels"> |
|
0 commit comments