Add option for new page to not add the page to config.toml
This commit is contained in:
parent
52b2bab5fd
commit
5f2b40ad43
@ -12,10 +12,10 @@ items = ["about", "other", "google"]
|
|||||||
title = "Google!"
|
title = "Google!"
|
||||||
link = "https://google.com"
|
link = "https://google.com"
|
||||||
|
|
||||||
[navbar.item.about]
|
|
||||||
title = "About"
|
|
||||||
link = "/"
|
|
||||||
|
|
||||||
[navbar.item.other]
|
[navbar.item.other]
|
||||||
title = "Other"
|
title = "Other"
|
||||||
link = "/other"
|
link = "/other"
|
||||||
|
|
||||||
|
[navbar.item.about]
|
||||||
|
title = "About"
|
||||||
|
link = "/"
|
||||||
|
@ -109,31 +109,33 @@ pub fn generate_new_page(ops: NewOps, logger: &Logger) -> Result<(), Error> {
|
|||||||
|
|
||||||
file_writer::write_file(markdown_path, PLACEHOLDER_MARKDOWN, ops.overwrite)?;
|
file_writer::write_file(markdown_path, PLACEHOLDER_MARKDOWN, ops.overwrite)?;
|
||||||
|
|
||||||
logger.log(
|
if !ops.no_modify_config {
|
||||||
LogLevel::INFO,
|
logger.log(
|
||||||
format!("Adding page config path to config.toml"),
|
LogLevel::INFO,
|
||||||
);
|
format!("Adding page config path to config.toml"),
|
||||||
let mut config = GlobalConfigToml::get_config()?;
|
);
|
||||||
config
|
let mut config = GlobalConfigToml::get_config()?;
|
||||||
.website
|
config
|
||||||
.built_pages
|
.website
|
||||||
.push(toml_path.to_str().unwrap().to_owned());
|
.built_pages
|
||||||
|
.push(toml_path.to_str().unwrap().to_owned());
|
||||||
|
|
||||||
logger.log(
|
logger.log(
|
||||||
LogLevel::DETAIL,
|
LogLevel::DETAIL,
|
||||||
format!("Re-serializing config and writing it"),
|
format!("Re-serializing config and writing it"),
|
||||||
);
|
);
|
||||||
|
|
||||||
match toml::ser::to_string(&config) {
|
match toml::ser::to_string(&config) {
|
||||||
Ok(text) => file_writer::write_file(PathBuf::from("config.toml"), text, ops.overwrite)?,
|
Ok(text) => file_writer::write_file(PathBuf::from("config.toml"), text, ops.overwrite)?,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Err(Error::new(
|
return Err(Error::new(
|
||||||
LogLevel::SEVERE,
|
LogLevel::SEVERE,
|
||||||
format!(
|
format!(
|
||||||
"Failed to serialize config.toml: {}",
|
"Failed to serialize config.toml: {}",
|
||||||
err.description().to_owned()
|
err.description().to_owned()
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,4 +50,7 @@ pub struct NewOps {
|
|||||||
/// Overwrites existing .toml / .md files
|
/// Overwrites existing .toml / .md files
|
||||||
#[structopt(short = "o", long = "overwrite")]
|
#[structopt(short = "o", long = "overwrite")]
|
||||||
pub overwrite: bool,
|
pub overwrite: bool,
|
||||||
|
/// Don't modify config.toml automatically
|
||||||
|
#[structopt(short = "n", long = "no-modify-config")]
|
||||||
|
pub no_modify_config: bool,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user