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 <fcastelli@suse.com>
This commit is contained in:
parent
94e797fba0
commit
7525b35383
|
@ -11,7 +11,7 @@ edition = "2018"
|
||||||
mathjax-support = true
|
mathjax-support = true
|
||||||
site-url = "/mdBook/"
|
site-url = "/mdBook/"
|
||||||
git-repository-url = "https://github.com/rust-lang/mdBook/tree/master/guide"
|
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]
|
[output.html.playground]
|
||||||
editable = true
|
editable = true
|
||||||
|
|
|
@ -201,10 +201,9 @@ The following configuration options are available:
|
||||||
an icon link will be output in the menu bar of the book.
|
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
|
- **git-repository-icon:** The FontAwesome icon class to use for the git
|
||||||
repository link. Defaults to `fa-github`.
|
repository link. Defaults to `fa-github`.
|
||||||
- **git-repository-edit-url-template:** Git repository file edit url
|
- **edit-url-template:** Edit url template, when provided shows a
|
||||||
template, when provided shows an "Suggest an edit" button for
|
"Suggest an edit" button for directly jumping to editing the currently
|
||||||
directly jumping to editing the currently viewed page in the git
|
viewed page. For e.g. GitHub projects set this to
|
||||||
repository. For e.g. GitHub projects set this to
|
|
||||||
`https://github.com/<owner>/<repo>/edit/master/{path}` or for
|
`https://github.com/<owner>/<repo>/edit/master/{path}` or for
|
||||||
Bitbucket projects set it to
|
Bitbucket projects set it to
|
||||||
`https://bitbucket.org/<owner>/<repo>/src/master/{path}?mode=edit`
|
`https://bitbucket.org/<owner>/<repo>/src/master/{path}?mode=edit`
|
||||||
|
@ -295,7 +294,7 @@ additional-js = ["custom.js"]
|
||||||
no-section-label = false
|
no-section-label = false
|
||||||
git-repository-url = "https://github.com/rust-lang/mdBook"
|
git-repository-url = "https://github.com/rust-lang/mdBook"
|
||||||
git-repository-icon = "fa-github"
|
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/"
|
site-url = "/example-book/"
|
||||||
cname = "myproject.rs"
|
cname = "myproject.rs"
|
||||||
input-404 = "not-found.md"
|
input-404 = "not-found.md"
|
||||||
|
|
|
@ -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
|
/// [custom domain]: https://docs.github.com/en/github/working-with-github-pages/managing-a-custom-domain-for-your-github-pages-site
|
||||||
pub cname: Option<String>,
|
pub cname: Option<String>,
|
||||||
/// Git repository file edit url template, when set shows an
|
/// Edit url template, when set shows a "Suggest an edit" button for
|
||||||
/// "Suggest an edit" button for directly jumping to editing the
|
/// directly jumping to editing the currently viewed page.
|
||||||
/// currently viewed page in the git repository. Contains {path}
|
/// Contains {path} that is replaced with chapter source file path
|
||||||
/// that is replaced with chapter source file path
|
pub edit_url_template: Option<String>,
|
||||||
pub git_repository_edit_url_template: Option<String>,
|
|
||||||
/// This is used as a bit of a workaround for the `mdbook serve` command.
|
/// 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
|
/// 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
|
/// `mdbook serve` command needs a way to let the HTML renderer know where
|
||||||
|
@ -559,7 +558,7 @@ impl Default for HtmlConfig {
|
||||||
search: None,
|
search: None,
|
||||||
git_repository_url: None,
|
git_repository_url: None,
|
||||||
git_repository_icon: None,
|
git_repository_icon: None,
|
||||||
git_repository_edit_url_template: None,
|
edit_url_template: None,
|
||||||
input_404: None,
|
input_404: None,
|
||||||
site_url: None,
|
site_url: None,
|
||||||
cname: None,
|
cname: None,
|
||||||
|
|
|
@ -37,16 +37,14 @@ impl HtmlHandlebars {
|
||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(ref git_repository_edit_url_template) =
|
if let Some(ref edit_url_template) = ctx.html_config.edit_url_template {
|
||||||
ctx.html_config.git_repository_edit_url_template
|
|
||||||
{
|
|
||||||
let full_path = "src/".to_owned()
|
let full_path = "src/".to_owned()
|
||||||
+ ch.source_path
|
+ ch.source_path
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap_or_default();
|
.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
|
ctx.data
|
||||||
.insert("git_repository_edit_url".to_owned(), json!(edit_url));
|
.insert("git_repository_edit_url".to_owned(), json!(edit_url));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue