Skip to content

Commit 9b0ccfb

Browse files
committed
Fix fa-github repository icon
1 parent 98b032c commit 9b0ccfb

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

guide/src/format/configuration/renderers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The following configuration options are available:
4343
- **git-repository-url:** A url to the git repository for the book. If provided
4444
an icon link will be output in the menu bar of the book.
4545
- **git-repository-icon:** The FontAwesome icon class to use for the git
46-
repository link. Defaults to `fa-github`.
46+
repository link. Defaults to `fab-github`.
4747
- **edit-url-template:** Edit url template, when provided shows a
4848
"Suggest an edit" button for directly jumping to editing the currently
4949
viewed page. For e.g. GitHub projects set this to
@@ -135,7 +135,7 @@ additional-css = ["custom.css", "custom2.css"]
135135
additional-js = ["custom.js"]
136136
no-section-label = false
137137
git-repository-url = "https://github.com/rust-lang/mdBook"
138-
git-repository-icon = "fa-github"
138+
git-repository-icon = "fab-github"
139139
edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}"
140140
site-url = "/example-book/"
141141
cname = "myproject.rs"

guide/src/format/mdbook.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ contents (sidebar) by including a `\{{#title ...}}` near the top of the page.
205205
## Font-Awesome icons
206206

207207
mdBook includes a copy of [Font Awesome Free's](https://fontawesome.com)
208-
MIT-licensed SVG files. It emulates the `<i class="fa">` syntax, but converts
209-
the results to inline SVG. Only the regular, solid, and brands icons are
210-
included; paid features like the light icons are not.
208+
MIT-licensed SVG files. It emulates the `<i>` syntax, but converts the results
209+
to inline SVG. Only the regular, solid, and brands icons are included; paid
210+
features like the light icons are not.
211211

212212
For example, given this HTML syntax:
213213

guide/src/format/theme/index-hbs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ They are used like this
8787
```handlebars
8888
{{#previous}}
8989
<a href="{{link}}" class="nav-chapters previous">
90-
<i class="fa fa-angle-left"></i>
90+
{{fa "solid" "angle-left"}}
9191
</a>
9292
{{/previous}}
9393
```

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,19 @@ fn make_data(
665665

666666
let git_repository_icon = match html_config.git_repository_icon {
667667
Some(ref git_repository_icon) => git_repository_icon,
668-
None => "fa-github",
668+
None => "fab-github",
669+
};
670+
let git_repository_icon_class = match git_repository_icon.split('-').next() {
671+
Some("fa") => "regular",
672+
Some("fas") => "solid",
673+
Some("fab") => "brands",
674+
_ => "regular",
669675
};
670676
data.insert("git_repository_icon".to_owned(), json!(git_repository_icon));
677+
data.insert(
678+
"git_repository_icon_class".to_owned(),
679+
json!(git_repository_icon_class),
680+
);
671681

672682
let mut chapters = vec![];
673683

src/renderer/html_handlebars/helpers/fontawesome.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ pub fn fa_helper(
2727

2828
let name = if name.starts_with("fa-") {
2929
&name[3..]
30+
} else if name.starts_with("fab-") {
31+
&name[4..]
32+
} else if name.starts_with("fas-") {
33+
&name[4..]
3034
} else {
3135
&name[..]
3236
};

src/theme/index.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
{{/if}}
145145
{{#if git_repository_url}}
146146
<a href="{{git_repository_url}}" title="Git repository" aria-label="Git repository">
147-
{{fa "solid" git_repository_icon}}
147+
{{fa git_repository_icon_class git_repository_icon}}
148148
</a>
149149
{{/if}}
150150
{{#if git_repository_edit_url}}

0 commit comments

Comments
 (0)