Skip to content

Commit ec0479e

Browse files
committed
Fix fa-github repository icon
1 parent f5d4f6e commit ec0479e

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
@@ -104,7 +104,7 @@ additional-css = ["custom.css", "custom2.css"]
104104
additional-js = ["custom.js"]
105105
no-section-label = false
106106
git-repository-url = "https://github.com/rust-lang/mdBook"
107-
git-repository-icon = "fa-github"
107+
git-repository-icon = "fab-github"
108108
edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}"
109109
site-url = "/example-book/"
110110
cname = "myproject.rs"
@@ -142,7 +142,7 @@ The following configuration options are available:
142142
- **git-repository-url:** A url to the git repository for the book. If provided
143143
an icon link will be output in the menu bar of the book.
144144
- **git-repository-icon:** The FontAwesome icon class to use for the git
145-
repository link. Defaults to `fa-github` which looks like <i class="fa fa-github"></i>.
145+
repository link. Defaults to `fab-github` which looks like <i class="fa fab-github"></i>.
146146
If you are not using GitHub, another option to consider is `fa-code-fork` which looks like <i class="fa fa-code-fork"></i>.
147147
- **edit-url-template:** Edit url template, when provided shows a
148148
"Suggest an edit" button (which looks like <i class="fa fa-edit"></i>) for directly jumping to editing the currently

guide/src/format/mdbook.md

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

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

285285
For example, given this HTML syntax:
286286

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
@@ -681,9 +681,19 @@ fn make_data(
681681

682682
let git_repository_icon = match html_config.git_repository_icon {
683683
Some(ref git_repository_icon) => git_repository_icon,
684-
None => "fa-github",
684+
None => "fab-github",
685+
};
686+
let git_repository_icon_class = match git_repository_icon.split('-').next() {
687+
Some("fa") => "regular",
688+
Some("fas") => "solid",
689+
Some("fab") => "brands",
690+
_ => "regular",
685691
};
686692
data.insert("git_repository_icon".to_owned(), json!(git_repository_icon));
693+
data.insert(
694+
"git_repository_icon_class".to_owned(),
695+
json!(git_repository_icon_class),
696+
);
687697

688698
let mut chapters = vec![];
689699

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)