This commit is contained in:
JMARyA 2024-12-30 23:21:48 +01:00
parent 5cbc7ef0d2
commit e50d31479c
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -1,4 +1,4 @@
use std::path::PathBuf; use std::{io::Read, path::PathBuf};
use based::request::RequestContext; use based::request::RequestContext;
use maud::html; use maud::html;
@ -189,17 +189,23 @@ impl Document {
format!("index_{version}.html") format!("index_{version}.html")
} else { } else {
let versions = self.versions(); let versions = self.versions();
versions.first().cloned()? let version = versions.first().cloned()?;
format!("index_{version}.html")
}; };
file_path = file_path.join(format!("index_{}.html", latest_version)); file_path = file_path.join(latest_version);
let content = std::fs::read_to_string(file_path).ok()?; let mut buf = Vec::new();
std::fs::File::open(file_path)
.unwrap()
.read_to_end(&mut buf)
.unwrap();
let content = String::from_utf8_lossy(&buf);
if std::env::var("ROUTE_INTERNAL").unwrap_or("false".to_string()) == "true" { if std::env::var("ROUTE_INTERNAL").unwrap_or("false".to_string()) == "true" {
Some(internalize_urls(&content)) Some(internalize_urls(&content))
} else { } else {
Some(content) Some(content.to_string())
} }
} }