fix: content_font compatibility

This commit is contained in:
trisua 2025-07-25 23:01:45 -04:00
parent 5d1a49ab06
commit 5d4e94575b

View file

@ -477,12 +477,21 @@ impl EntryMetadata {
}
if !self.content_font.is_empty() {
let s: Vec<&str> = self.content_font.split(" ").collect();
output.push_str(&format!(
"<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">
<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>
<link href=\"https://fonts.googleapis.com/css2?family={}&display=swap\" rel=\"stylesheet\">",
self.content_font.replace(" ", "+").replace("_", "+"),
"<link href=\"https://fonts.googleapis.com/css2?family={}&display=swap\" rel=\"stylesheet\">",
s[0].replace("_", "+"),
));
if let Some(headings) = s.get(1) {
output.push_str(&format!(
"<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">
<link rel=\"preconnect\" href=\"https://fonts.gstatic.com\" crossorigin>
<link href=\"https://fonts.googleapis.com/css2?family={}&display=swap\" rel=\"stylesheet\">",
headings.replace("_", "+"),
));
}
}
if self.option_disable_search_engine {
@ -571,10 +580,19 @@ impl EntryMetadata {
}
if !self.content_font.is_empty() {
let s: Vec<&str> = self.content_font.split(" ").collect();
output.push_str(&format!(
".container {{ font-family: \"{}\", system-ui; }}",
self.content_font.replace("_", " ")
s[0].replace("_", " ")
));
if let Some(headings) = s.get(1) {
output.push_str(&format!(
".container h1, .container h2, .container h3, .container h4, .container h5, .container h6 {{ font-family: \"{}\", system-ui; }}",
headings.replace("_", " ")
));
}
}
if self.content_font_weight != 0 {