mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 14:52:37 +00:00
Initial implementation of a git repository button
This commit is contained in:
parent
0c926b3e88
commit
599e47f1f1
4 changed files with 15 additions and 1 deletions
|
@ -440,6 +440,8 @@ pub struct HtmlConfig {
|
|||
pub no_section_label: bool,
|
||||
/// Search settings. If `None`, the default will be used.
|
||||
pub search: Option<Search>,
|
||||
/// Git repository url. If 'None', the git button will not be shown.
|
||||
pub git_repository_url: Option<String>,
|
||||
}
|
||||
|
||||
impl HtmlConfig {
|
||||
|
|
|
@ -454,6 +454,10 @@ fn make_data(
|
|||
)
|
||||
}
|
||||
|
||||
if let Some(ref git_repository_url) = html_config.git_repository_url {
|
||||
data.insert("git-repository-url".to_owned(), json!(git_repository_url));
|
||||
}
|
||||
|
||||
let mut chapters = vec![];
|
||||
|
||||
for item in book.iter() {
|
||||
|
|
|
@ -63,9 +63,12 @@ a > .hljs {
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
#print-button {
|
||||
.right-buttons {
|
||||
margin: 0 15px;
|
||||
}
|
||||
.right-buttons a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
html:not(.sidebar-visible) #menu-bar:not(:hover).folded > #menu-bar-sticky-container {
|
||||
transform: translateY(-60px);
|
||||
|
|
|
@ -113,6 +113,11 @@
|
|||
<a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book">
|
||||
<i id="print-button" class="fa fa-print"></i>
|
||||
</a>
|
||||
{{#if git-repository-url}}
|
||||
<a href="{{git-repository-url}}" title="Git repository" aria-label="Git repository">
|
||||
<i id="github-button" class="fa fa-git"></i>
|
||||
</a>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue