Create output directory after processing html

Signed-off-by: Evan Lloyd New-Schmidt <evan@new-schmidt.com>
This commit is contained in:
Evan Lloyd New-Schmidt 2023-09-29 15:14:03 -04:00 committed by Evan Lloyd New-Schmidt
parent 1da8ec212a
commit 9858994f93

View file

@ -270,19 +270,6 @@ fn write(
redirects: impl IntoIterator<Item = Title>,
simplify: bool,
) -> anyhow::Result<()> {
let article_dir = create_article_dir(&base, page, redirects)?;
// Write html to determined file.
let mut filename = article_dir;
filename.push(&page.in_language.identifier);
filename.set_extension("html");
debug!("{:?}: {:?}", page.name, filename);
if filename.exists() {
debug!("Overwriting existing file");
}
let html = if simplify {
match html::simplify(&page.article_body.html, &page.in_language.identifier) {
Ok(html) => html,
@ -310,6 +297,19 @@ fn write(
page.article_body.html.to_string()
};
let article_dir = create_article_dir(&base, page, redirects)?;
// Write html to determined file.
let mut filename = article_dir;
filename.push(&page.in_language.identifier);
filename.set_extension("html");
debug!("{:?}: {:?}", page.name, filename);
if filename.exists() {
debug!("Overwriting existing file");
}
let mut file =
File::create(&filename).with_context(|| format!("creating html file {:?}", filename))?;
file.write_all(html.as_bytes())