Skip to content

Commit

Permalink
Add subproject canonical URLs to search result return
Browse files Browse the repository at this point in the history
  • Loading branch information
agjohnson committed Feb 23, 2016
1 parent 8f36ce5 commit c6f3d6e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions readthedocs/core/static-src/core/js/doc-embed/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function attach_elastic_search_query(data) {
version = data.version,
language = data.language || 'en',
api_host = data.api_host,
subprojects = data.subprojects || {},
canonical_url = data.canonical_url || "/";

var query_override = function (query) {
Expand All @@ -46,6 +47,10 @@ function attach_elastic_search_query(data) {
highlight = hit.highlight;

item_url.href = canonical_url;
if (fields.project != project) {
var subproject_url = subprojects[fields.project];
item_url.href = subproject_url;
}
item_url += fields.path + DOCUMENTATION_OPTIONS.FILE_SUFFIX;
item_url.search = '?highlight=' + $.urlencode(query);

Expand Down
Loading

0 comments on commit c6f3d6e

Please sign in to comment.