Skip to content

Commit

Permalink
Fix fa-github repository icon
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Apr 14, 2021
1 parent c574c3e commit 96c3719
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions guide/src/format/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,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`.
repository link. Defaults to `fab-github`.
- **redirect:** A subtable used for generating redirects when a page is moved.
The table contains key-value pairs where the key is where the redirect file
needs to be created, as an absolute path from the build directory, (e.g.
Expand Down Expand Up @@ -285,7 +285,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"
site-url = "/example-book/"
cname = "myproject.rs"
input-404 = "not-found.md"
Expand Down
6 changes: 3 additions & 3 deletions guide/src/format/mdbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,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 `<i class="fa">` 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 `<i>` 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:

Expand Down
2 changes: 1 addition & 1 deletion guide/src/format/theme/index-hbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ They are used like this
```handlebars
{{#previous}}
<a href="{{link}}" class="nav-chapters previous">
<i class="fa fa-angle-left"></i>
{{fa "solid" "angle-left"}}
</a>
{{/previous}}
```
Expand Down
12 changes: 11 additions & 1 deletion src/renderer/html_handlebars/hbs_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,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![];

Expand Down
4 changes: 4 additions & 0 deletions src/renderer/html_handlebars/helpers/fontawesome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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[..]
};
Expand Down
2 changes: 1 addition & 1 deletion src/theme/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
{{/if}}
{{#if git_repository_url}}
<a href="{{git_repository_url}}" title="Git repository" aria-label="Git repository">
{{fa "solid" git_repository_icon}}
{{fa git_repository_icon_class git_repository_icon}}
</a>
{{/if}}
</div>
Expand Down

0 comments on commit 96c3719

Please sign in to comment.