Skip to content

Commit 7525b35

Browse files
committed
Rename git-repository-edit-url-template
Change the name of the git-repository-edit-url-template to be more generic: `edit-url-template` Signed-off-by: Flavio Castelli <[email protected]>
1 parent 94e797f commit 7525b35

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

guide/book.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ edition = "2018"
1111
mathjax-support = true
1212
site-url = "/mdBook/"
1313
git-repository-url = "https://github.com/rust-lang/mdBook/tree/master/guide"
14-
git-repository-edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}"
14+
edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}"
1515

1616
[output.html.playground]
1717
editable = true

guide/src/format/config.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,9 @@ The following configuration options are available:
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
203203
repository link. Defaults to `fa-github`.
204-
- **git-repository-edit-url-template:** Git repository file edit url
205-
template, when provided shows an "Suggest an edit" button for
206-
directly jumping to editing the currently viewed page in the git
207-
repository. For e.g. GitHub projects set this to
204+
- **edit-url-template:** Edit url template, when provided shows a
205+
"Suggest an edit" button for directly jumping to editing the currently
206+
viewed page. For e.g. GitHub projects set this to
208207
`https://github.com/<owner>/<repo>/edit/master/{path}` or for
209208
Bitbucket projects set it to
210209
`https://bitbucket.org/<owner>/<repo>/src/master/{path}?mode=edit`
@@ -295,7 +294,7 @@ additional-js = ["custom.js"]
295294
no-section-label = false
296295
git-repository-url = "https://github.com/rust-lang/mdBook"
297296
git-repository-icon = "fa-github"
298-
git-repository-edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}"
297+
edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}"
299298
site-url = "/example-book/"
300299
cname = "myproject.rs"
301300
input-404 = "not-found.md"

src/config.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,10 @@ pub struct HtmlConfig {
522522
///
523523
/// [custom domain]: https://docs.github.com/en/github/working-with-github-pages/managing-a-custom-domain-for-your-github-pages-site
524524
pub cname: Option<String>,
525-
/// Git repository file edit url template, when set shows an
526-
/// "Suggest an edit" button for directly jumping to editing the
527-
/// currently viewed page in the git repository. Contains {path}
528-
/// that is replaced with chapter source file path
529-
pub git_repository_edit_url_template: Option<String>,
525+
/// Edit url template, when set shows a "Suggest an edit" button for
526+
/// directly jumping to editing the currently viewed page.
527+
/// Contains {path} that is replaced with chapter source file path
528+
pub edit_url_template: Option<String>,
530529
/// This is used as a bit of a workaround for the `mdbook serve` command.
531530
/// Basically, because you set the websocket port from the command line, the
532531
/// `mdbook serve` command needs a way to let the HTML renderer know where
@@ -559,7 +558,7 @@ impl Default for HtmlConfig {
559558
search: None,
560559
git_repository_url: None,
561560
git_repository_icon: None,
562-
git_repository_edit_url_template: None,
561+
edit_url_template: None,
563562
input_404: None,
564563
site_url: None,
565564
cname: None,

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,14 @@ impl HtmlHandlebars {
3737
_ => return Ok(()),
3838
};
3939

40-
if let Some(ref git_repository_edit_url_template) =
41-
ctx.html_config.git_repository_edit_url_template
42-
{
40+
if let Some(ref edit_url_template) = ctx.html_config.edit_url_template {
4341
let full_path = "src/".to_owned()
4442
+ ch.source_path
4543
.clone()
4644
.unwrap_or_default()
4745
.to_str()
4846
.unwrap_or_default();
49-
let edit_url = git_repository_edit_url_template.replace("{path}", &full_path);
47+
let edit_url = edit_url_template.replace("{path}", &full_path);
5048
ctx.data
5149
.insert("git_repository_edit_url".to_owned(), json!(edit_url));
5250
}

0 commit comments

Comments
 (0)