mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-12 22:02:37 +00:00
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
4 changed files with 12 additions and 16 deletions
|
@ -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
|
||||
|
|
|
@ -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/<owner>/<repo>/edit/master/{path}` or for
|
||||
Bitbucket projects set it to
|
||||
`https://bitbucket.org/<owner>/<repo>/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"
|
||||
|
|
|
@ -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<String>,
|
||||
/// 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<String>,
|
||||
/// 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<String>,
|
||||
/// 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,
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue