diff --git a/guide/book.toml b/guide/book.toml index f77c28cf..a37c2a7f 100644 --- a/guide/book.toml +++ b/guide/book.toml @@ -11,7 +11,7 @@ edition = "2018" mathjax-support = true site-url = "/mdBook/" git-repository-url = "https://github.com/rust-lang/mdBook/tree/master/guide" -git-repository-edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}" +edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}" [output.html.playground] editable = true diff --git a/guide/src/format/config.md b/guide/src/format/config.md index f43c56a6..b3110194 100644 --- a/guide/src/format/config.md +++ b/guide/src/format/config.md @@ -201,10 +201,9 @@ The following configuration options are available: an icon link will be output in the menu bar of the book. - **git-repository-icon:** The FontAwesome icon class to use for the git repository link. Defaults to `fa-github`. -- **git-repository-edit-url-template:** Git repository file edit url - template, when provided shows an "Suggest an edit" button for - directly jumping to editing the currently viewed page in the git - repository. For e.g. GitHub projects set this to +- **edit-url-template:** Edit url template, when provided shows a + "Suggest an edit" button for directly jumping to editing the currently + viewed page. For e.g. GitHub projects set this to `https://github.com///edit/master/{path}` or for Bitbucket projects set it to `https://bitbucket.org///src/master/{path}?mode=edit` @@ -295,7 +294,7 @@ additional-js = ["custom.js"] no-section-label = false git-repository-url = "https://github.com/rust-lang/mdBook" git-repository-icon = "fa-github" -git-repository-edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}" +edit-url-template = "https://github.com/rust-lang/mdBook/edit/master/guide/{path}" site-url = "/example-book/" cname = "myproject.rs" input-404 = "not-found.md" diff --git a/src/config.rs b/src/config.rs index e80e21c4..78fdc3ad 100644 --- a/src/config.rs +++ b/src/config.rs @@ -522,11 +522,10 @@ pub struct HtmlConfig { /// /// [custom domain]: https://docs.github.com/en/github/working-with-github-pages/managing-a-custom-domain-for-your-github-pages-site pub cname: Option, - /// Git repository file edit url template, when set shows an - /// "Suggest an edit" button for directly jumping to editing the - /// currently viewed page in the git repository. Contains {path} - /// that is replaced with chapter source file path - pub git_repository_edit_url_template: Option, + /// Edit url template, when set shows a "Suggest an edit" button for + /// directly jumping to editing the currently viewed page. + /// Contains {path} that is replaced with chapter source file path + pub edit_url_template: Option, /// This is used as a bit of a workaround for the `mdbook serve` command. /// Basically, because you set the websocket port from the command line, the /// `mdbook serve` command needs a way to let the HTML renderer know where @@ -559,7 +558,7 @@ impl Default for HtmlConfig { search: None, git_repository_url: None, git_repository_icon: None, - git_repository_edit_url_template: None, + edit_url_template: None, input_404: None, site_url: None, cname: None, diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index e1cbab71..56324331 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -37,16 +37,14 @@ impl HtmlHandlebars { _ => return Ok(()), }; - if let Some(ref git_repository_edit_url_template) = - ctx.html_config.git_repository_edit_url_template - { + if let Some(ref edit_url_template) = ctx.html_config.edit_url_template { let full_path = "src/".to_owned() + ch.source_path .clone() .unwrap_or_default() .to_str() .unwrap_or_default(); - let edit_url = git_repository_edit_url_template.replace("{path}", &full_path); + let edit_url = edit_url_template.replace("{path}", &full_path); ctx.data .insert("git_repository_edit_url".to_owned(), json!(edit_url)); }