-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add breadcrumbs to JAR, group, and security pages
Google uses breadcrumbs to present search results in a cleaner fashion. This will probably need to be revisited once #482 is decided.
- Loading branch information
1 parent
f448984
commit aea8653
Showing
6 changed files
with
67 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,7 @@ | |
[clojure.string :as str])) | ||
|
||
(def common "Common ld-json attributes" | ||
{"@context" "http://schema.org" | ||
"url" "https://clojars.org"}) | ||
{"@context" "http://schema.org"}) | ||
|
||
(defn ld-json | ||
"Takes a map m, converts it to JSON, and puts it inside | ||
|
@@ -21,6 +20,7 @@ | |
(def website | ||
(ld-json | ||
{"@type" "WebSite" | ||
"url" "https://clojars.org" | ||
"name" "Clojars" ;; https://developers.google.com/structured-data/site-name | ||
"sameAs" ["https://twitter.com/clojars"] ;; https://developers.google.com/structured-data/customize/social-profiles | ||
"potentialAction" ;; https://developers.google.com/structured-data/slsb-overview | ||
|
@@ -31,6 +31,7 @@ | |
(def organisation | ||
(ld-json | ||
{"@type" "Organization" | ||
"url" "https://clojars.org" | ||
"name" "Clojars" | ||
"logo" "https://clojars.org/images/[email protected]"})) | ||
|
||
|
@@ -72,3 +73,31 @@ | |
(meta-property "og:title" (:title ctx)) | ||
(meta-property "og:description" (:description ctx)) | ||
(meta-property "og:image" (or (:image-url ctx) "https://clojars.org/images/[email protected]")))) | ||
|
||
(defn breadcrumbs [crumbs] | ||
(println crumbs) | ||
(ld-json | ||
{"@type" "BreadcrumbList" | ||
"itemListElement" (into [] (map-indexed (fn [index crumb] | ||
{"@type" "ListItem" | ||
"position" (inc index) | ||
"item" {"@id" (:url crumb) | ||
"name" (:name crumb)}})) | ||
crumbs) | ||
|
||
#_(if (group-is-name? jar) | ||
[{"@type" "ListItem" | ||
"position" 1 | ||
"item" {"@id" (str "https://clojars.org/" (jar-name jar)) | ||
"name" (:jar_name jar)}}] | ||
|
||
[{"@type" "ListItem" | ||
"position" 1 | ||
"item" {"@id" (str "https://clojars.org/groups/" (:group_name jar)) ;; Waiting on #482 | ||
"name" (:group_name jar)}} | ||
{"@type" "ListItem" | ||
"position" 2 | ||
"item" {"@id" (str "https://clojars.org/" (jar-name jar)) ;; TODO: Not sure if this is a dirty hack or a stroke of brilliance | ||
"name" (:jar_name jar)}}])}) | ||
|
||
) |