Skip to content

Commit

Permalink
Use theme-adaptive SVG favicon from other Rust sites
Browse files Browse the repository at this point in the history
  • Loading branch information
Cldfire committed Sep 24, 2020
1 parent c351775 commit 085679c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ pub fn render<T: Print, S: Print>(
keywords = page.keywords,
favicon = if layout.favicon.is_empty() {
format!(
r#"<link rel="shortcut icon" href="{static_root_path}favicon{suffix}.ico">"#,
r##"<link rel="icon" type="image/svg+xml" href="{static_root_path}favicon{suffix}.svg">
<link rel="alternate icon" type="image/png" href="{static_root_path}favicon-16x16{suffix}.png">
<link rel="alternate icon" type="image/png" href="{static_root_path}favicon-32x32{suffix}.png">"##,
static_root_path = static_root_path,
suffix = page.resource_suffix
)
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,9 @@ fn write_shared(
write(cx.path("rust-logo.png"), static_files::RUST_LOGO)?;
}
if (*cx.shared).layout.favicon.is_empty() {
write(cx.path("favicon.ico"), static_files::RUST_FAVICON)?;
write(cx.path("favicon.svg"), static_files::RUST_FAVICON_SVG)?;
write(cx.path("favicon-16x16.png"), static_files::RUST_FAVICON_PNG_16)?;
write(cx.path("favicon-32x32.png"), static_files::RUST_FAVICON_PNG_32)?;
}
write(cx.path("brush.svg"), static_files::BRUSH_SVG)?;
write(cx.path("wheel.svg"), static_files::WHEEL_SVG)?;
Expand Down
Binary file added src/librustdoc/html/static/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/librustdoc/html/static/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/librustdoc/html/static/favicon.ico
Binary file not shown.
24 changes: 24 additions & 0 deletions src/librustdoc/html/static/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions src/librustdoc/html/static_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ pub static LICENSE_MIT: &[u8] = include_bytes!("static/LICENSE-MIT.txt");

/// The contents of `rust-logo.png`, the default icon of the documentation.
pub static RUST_LOGO: &[u8] = include_bytes!("static/rust-logo.png");
/// The contents of `favicon.ico`, the default favicon of the documentation.
pub static RUST_FAVICON: &[u8] = include_bytes!("static/favicon.ico");
/// The default documentation favicons (SVG and PNG fallbacks)
pub static RUST_FAVICON_SVG: &[u8] = include_bytes!("static/favicon.svg");
pub static RUST_FAVICON_PNG_16: &[u8] = include_bytes!("static/favicon-16x16.png");
pub static RUST_FAVICON_PNG_32: &[u8] = include_bytes!("static/favicon-32x32.png");

/// The built-in themes given to every documentation site.
pub mod themes {
Expand Down

0 comments on commit 085679c

Please sign in to comment.