diff options
| author | Fuwn <[email protected]> | 2023-03-11 07:04:22 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-03-11 07:04:22 +0000 |
| commit | 695b73133e1ce462f912656d762d0de4bbed5e47 (patch) | |
| tree | 6ba3a2333fc846086ceb745db6bb4a303080e457 | |
| parent | ci(check.yaml): correct rust toolchain (diff) | |
| download | september-695b73133e1ce462f912656d762d0de4bbed5e47.tar.xz september-695b73133e1ce462f912656d762d0de4bbed5e47.zip | |
feat(response): allow multiple css files
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | src/response.rs | 13 |
2 files changed, 10 insertions, 5 deletions
@@ -72,7 +72,7 @@ ROOT=gemini://fuwn.me ### `CSS_EXTERNAL` -An external CSS file to apply to the HTML response. +A comma-seperated list of external CSS files to apply to the HTML response. If no `CSS_EXTERNAL` is provided, there will be no styling done to the HTML response. diff --git a/src/response.rs b/src/response.rs index 547cf12..393e3b8 100644 --- a/src/response.rs +++ b/src/response.rs @@ -141,10 +141,15 @@ pub async fn default( // Try to add an external stylesheet from the `CSS_EXTERNAL` environment // variable. if let Ok(css) = var("CSS_EXTERNAL") { - html_context.push_str(&format!( - "<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">", - css - )); + let stylesheets = + css.split(',').filter(|s| !s.is_empty()).collect::<Vec<_>>(); + + for stylesheet in stylesheets { + html_context.push_str(&format!( + "<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">", + stylesheet, + )); + } } // Try to add an external favicon from the `FAVICON_EXTERNAL` environment |