Add page title override: {{#title My Title}} (#1381)

* Add page title override: {{#title My Title}}

* Document {{#title}} in guide
This commit is contained in:
David Tolnay 2021-03-23 18:36:45 -07:00 committed by Ruben Moor
parent 6df36232bd
commit 59073b1084
1 changed files with 8 additions and 0 deletions

View File

@ -139,6 +139,7 @@ enum LinkType<'a> {
RustdocInclude(PathBuf, RangeOrAnchor), RustdocInclude(PathBuf, RangeOrAnchor),
Title(&'a str), Title(&'a str),
Template(PathBuf, HashMap<String, String>), Template(PathBuf, HashMap<String, String>),
Title(&'a str),
} }
#[derive(PartialEq, Debug, Clone)] #[derive(PartialEq, Debug, Clone)]
@ -211,6 +212,7 @@ impl<'a> LinkType<'a> {
LinkType::RustdocInclude(p, _) => Some(return_relative_path(base, &p)), LinkType::RustdocInclude(p, _) => Some(return_relative_path(base, &p)),
LinkType::Title(_) => None, LinkType::Title(_) => None,
LinkType::Template(p, _) => Some(return_relative_path(base, &p)), LinkType::Template(p, _) => Some(return_relative_path(base, &p)),
LinkType::Title(_) => None,
} }
} }
} }
@ -401,6 +403,7 @@ impl<'a> Link<'a> {
LinkType::Title(title) => { LinkType::Title(title) => {
*chapter_title = title.to_owned(); *chapter_title = title.to_owned();
Ok(String::new()) Ok(String::new())
}
LinkType::Template(ref pat, ref dict) => { LinkType::Template(ref pat, ref dict) => {
let target = base.join(pat); let target = base.join(pat);
fs::read_to_string(&target) fs::read_to_string(&target)
@ -423,6 +426,11 @@ impl<'a> Link<'a> {
) )
}) })
} }
LinkType::Title(title) => {
*chapter_title = title.to_owned();
Ok(String::new())
}
} }
} }
} }