Skip to content

Commit de13cfa

Browse files
committed
Fix fa-github repository icon
1 parent c574c3e commit de13cfa

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

guide/src/format/config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ The following configuration options are available:
200200
- **git-repository-url:** A url to the git repository for the book. If provided
201201
an icon link will be output in the menu bar of the book.
202202
- **git-repository-icon:** The FontAwesome icon class to use for the git
203-
repository link. Defaults to `fa-github`.
203+
repository link. Defaults to `fab-github`.
204204
- **redirect:** A subtable used for generating redirects when a page is moved.
205205
The table contains key-value pairs where the key is where the redirect file
206206
needs to be created, as an absolute path from the build directory, (e.g.
@@ -285,7 +285,7 @@ additional-css = ["custom.css", "custom2.css"]
285285
additional-js = ["custom.js"]
286286
no-section-label = false
287287
git-repository-url = "https://github.com/rust-lang/mdBook"
288-
git-repository-icon = "fa-github"
288+
git-repository-icon = "fab-github"
289289
site-url = "/example-book/"
290290
cname = "myproject.rs"
291291
input-404 = "not-found.md"

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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,16 @@ fn make_data(
651651

652652
let git_repository_icon = match html_config.git_repository_icon {
653653
Some(ref git_repository_icon) => git_repository_icon,
654-
None => "fa-github",
654+
None => "fab-github",
655+
};
656+
let git_repository_icon_class = match git_repository_icon.split('-').next() {
657+
Some("fa") => "regular",
658+
Some("fas") => "solid",
659+
Some("fab") => "brands",
660+
_ => "regular",
655661
};
656662
data.insert("git_repository_icon".to_owned(), json!(git_repository_icon));
663+
data.insert("git_repository_icon_class".to_owned(), json!(git_repository_icon_class));
657664

658665
let mut chapters = vec![];
659666

src/renderer/html_handlebars/helpers/fontawesome.rs

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

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

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
</div>

0 commit comments

Comments
 (0)