File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -165,6 +165,7 @@ struct SourcePage {
165
165
show_parent_link : bool ,
166
166
file_content : Option < String > ,
167
167
is_rust_source : bool ,
168
+ canonical_url : String ,
168
169
}
169
170
170
171
impl_webpage ! {
@@ -232,6 +233,11 @@ pub fn source_browser_handler(req: &mut Request) -> IronResult<Response> {
232
233
( path, file_path)
233
234
} ;
234
235
236
+ let canonical_url = format ! (
237
+ "https://docs.rs/crate/{}/latest/source/{}" ,
238
+ crate_name, file_path
239
+ ) ;
240
+
235
241
let storage = extension ! ( req, Storage ) ;
236
242
let archive_storage: bool = {
237
243
let rows = ctry ! (
@@ -295,6 +301,7 @@ pub fn source_browser_handler(req: &mut Request) -> IronResult<Response> {
295
301
show_parent_link : !req_path. is_empty ( ) ,
296
302
file_content,
297
303
is_rust_source,
304
+ canonical_url,
298
305
}
299
306
. into_response ( req)
300
307
}
Original file line number Diff line number Diff line change 5
5
{{ macros::doc_title(name=file_list.metadata.name, version=file_list.metadata.version) }}
6
6
{%- endblock title -%}
7
7
8
+ {%- block meta -%}
9
+ < link rel ="canonical " href ="{{ canonical_url | safe }} " />
10
+ {%- endblock -%}
11
+
8
12
{%- block topbar -%}
9
13
{%- set metadata = file_list.metadata -%}
10
14
{%- set latest_version = "" -%}
You can’t perform that action at this time.
0 commit comments