diff --git a/guide/src/format/configuration/renderers.md b/guide/src/format/configuration/renderers.md index f1d5ee15aa..8c7046cdf9 100644 --- a/guide/src/format/configuration/renderers.md +++ b/guide/src/format/configuration/renderers.md @@ -104,7 +104,7 @@ additional-css = ["custom.css", "custom2.css"] additional-js = ["custom.js"] no-section-label = false git-repository-url = "https://github.com/rust-lang/mdBook" -git-repository-icon = "fa-github" +git-repository-icon = "fab-github" edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}" site-url = "/example-book/" cname = "myproject.rs" @@ -142,7 +142,7 @@ The following configuration options are available: - **git-repository-url:** A url to the git repository for the book. If provided an icon link will be output in the menu bar of the book. - **git-repository-icon:** The FontAwesome icon class to use for the git - repository link. Defaults to `fa-github` which looks like . + repository link. Defaults to `fab-github` which looks like . If you are not using GitHub, another option to consider is `fa-code-fork` which looks like . - **edit-url-template:** Edit url template, when provided shows a "Suggest an edit" button (which looks like ) for directly jumping to editing the currently diff --git a/guide/src/format/mdbook.md b/guide/src/format/mdbook.md index f653f9dde7..cdd3d9bd5f 100644 --- a/guide/src/format/mdbook.md +++ b/guide/src/format/mdbook.md @@ -278,9 +278,9 @@ contents (sidebar) by including a `\{{#title ...}}` near the top of the page. ## Font-Awesome icons mdBook includes a copy of [Font Awesome Free's](https://fontawesome.com) -MIT-licensed SVG files. It emulates the `` syntax, but converts -the results to inline SVG. Only the regular, solid, and brands icons are -included; paid features like the light icons are not. +MIT-licensed SVG files. It emulates the `` syntax, but converts the results +to inline SVG. Only the regular, solid, and brands icons are included; paid +features like the light icons are not. For example, given this HTML syntax: diff --git a/guide/src/format/theme/index-hbs.md b/guide/src/format/theme/index-hbs.md index d85ff59b2e..fae38ecfb0 100644 --- a/guide/src/format/theme/index-hbs.md +++ b/guide/src/format/theme/index-hbs.md @@ -87,7 +87,7 @@ They are used like this ```handlebars {{#previous}} {{/previous}} ``` diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index ceaeeda944..2988b3fae4 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -681,9 +681,19 @@ fn make_data( let git_repository_icon = match html_config.git_repository_icon { Some(ref git_repository_icon) => git_repository_icon, - None => "fa-github", + None => "fab-github", + }; + let git_repository_icon_class = match git_repository_icon.split('-').next() { + Some("fa") => "regular", + Some("fas") => "solid", + Some("fab") => "brands", + _ => "regular", }; data.insert("git_repository_icon".to_owned(), json!(git_repository_icon)); + data.insert( + "git_repository_icon_class".to_owned(), + json!(git_repository_icon_class), + ); let mut chapters = vec![]; diff --git a/src/renderer/html_handlebars/helpers/fontawesome.rs b/src/renderer/html_handlebars/helpers/fontawesome.rs index f0eb00c72c..46967cb0ac 100644 --- a/src/renderer/html_handlebars/helpers/fontawesome.rs +++ b/src/renderer/html_handlebars/helpers/fontawesome.rs @@ -27,6 +27,10 @@ pub fn fa_helper( let name = if name.starts_with("fa-") { &name[3..] + } else if name.starts_with("fab-") { + &name[4..] + } else if name.starts_with("fas-") { + &name[4..] } else { &name[..] }; diff --git a/src/theme/index.hbs b/src/theme/index.hbs index 002bf3ace3..f870bda454 100644 --- a/src/theme/index.hbs +++ b/src/theme/index.hbs @@ -144,7 +144,7 @@ {{/if}} {{#if git_repository_url}} - {{fa "solid" git_repository_icon}} + {{fa git_repository_icon_class git_repository_icon}} {{/if}} {{#if git_repository_edit_url}}