@@ -39,24 +39,26 @@ pub struct HtmlHeadCtx {
3939 script_js : String ,
4040 fuse_js : String ,
4141 url_search : String ,
42+ head_inject : Option < String > ,
4243 disable_search : bool ,
4344}
4445
4546impl HtmlHeadCtx {
4647 pub const TEMPLATE : & ' static str = "pages/html_head" ;
4748
4849 pub fn new (
50+ ctx : & GenerateCtx ,
4951 root : & str ,
5052 page : Option < & str > ,
51- package_name : Option < & String > ,
5253 current_file : Option < & ShortPath > ,
53- disable_search : bool ,
5454 ) -> Self {
5555 Self {
5656 title : format ! (
5757 "{}{}documentation" ,
5858 page. map( |page| format!( "{page} - " ) ) . unwrap_or_default( ) ,
59- package_name
59+ ctx
60+ . package_name
61+ . as_ref( )
6062 . map( |package_name| format!( "{package_name} " ) )
6163 . unwrap_or_default( )
6264 ) ,
@@ -71,7 +73,8 @@ impl HtmlHeadCtx {
7173 script_js : format ! ( "{root}{SCRIPT_FILENAME}" ) ,
7274 fuse_js : format ! ( "{root}{FUSE_FILENAME}" ) ,
7375 url_search : format ! ( "{root}{SEARCH_FILENAME}" ) ,
74- disable_search,
76+ head_inject : ctx. head_inject . clone ( ) . map ( |head_inject| head_inject ( root) ) ,
77+ disable_search : ctx. disable_search ,
7578 }
7679 }
7780}
@@ -232,6 +235,7 @@ impl IndexCtx {
232235 ctx. resolve_path ( render_ctx. get_current_resolve ( ) , UrlResolveKind :: Root ) ;
233236
234237 let html_head_ctx = HtmlHeadCtx :: new (
238+ ctx,
235239 & root,
236240 short_path. as_ref ( ) . and_then ( |short_path| {
237241 if short_path. is_main {
@@ -240,9 +244,7 @@ impl IndexCtx {
240244 Some ( short_path. display_name ( ) )
241245 }
242246 } ) ,
243- ctx. package_name . as_ref ( ) ,
244247 None ,
245- ctx. disable_search ,
246248 ) ;
247249
248250 let overview = match ctx. file_mode {
@@ -399,13 +401,7 @@ impl IndexCtx {
399401 let root =
400402 ctx. resolve_path ( UrlResolveKind :: Category ( name) , UrlResolveKind :: Root ) ;
401403
402- let html_head_ctx = HtmlHeadCtx :: new (
403- & root,
404- Some ( name) ,
405- ctx. package_name . as_ref ( ) ,
406- None ,
407- ctx. disable_search ,
408- ) ;
404+ let html_head_ctx = HtmlHeadCtx :: new ( ctx, & root, Some ( name) , None ) ;
409405
410406 let breadcrumbs_ctx = render_ctx. get_breadcrumbs ( ) ;
411407
@@ -463,13 +459,7 @@ impl AllSymbolsCtx {
463459 } ) ,
464460 ) ;
465461
466- let html_head_ctx = HtmlHeadCtx :: new (
467- "./" ,
468- Some ( "All Symbols" ) ,
469- ctx. package_name . as_ref ( ) ,
470- None ,
471- ctx. disable_search ,
472- ) ;
462+ let html_head_ctx = HtmlHeadCtx :: new ( ctx, "./" , Some ( "All Symbols" ) , None ) ;
473463
474464 let categories_panel = CategoriesPanelCtx :: new ( & render_ctx, None ) ;
475465
0 commit comments