diff options
| author | Ben Bridle <ben@derelict.engineering> | 2026-02-22 10:04:07 +1300 |
|---|---|---|
| committer | Ben Bridle <ben@derelict.engineering> | 2026-02-22 10:15:33 +1300 |
| commit | f7d67da481c8523a2cb09df057b5d17de459cd37 (patch) | |
| tree | e971253088f9f14a9168f581e6f38561cddc8faa | |
| parent | 700c0ddd79fc6ca01d52250b69b02c1a13d4ddef (diff) | |
| download | toaster-f7d67da481c8523a2cb09df057b5d17de459cd37.zip | |
Support linking to generated feeds
The has_static routine that checks whether links to static files are
valid now correctly considers generated feeds as static files.
| -rw-r--r-- | src/collect_files.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/collect_files.rs b/src/collect_files.rs index 3616c8a..d6d7cc2 100644 --- a/src/collect_files.rs +++ b/src/collect_files.rs @@ -453,8 +453,8 @@ impl Website { return None; } - /// Check if the external link `path` points to a valid static file. - /// Returns a resolved absolute link to the file. + /// Check if the external link `path` points to a valid static file or + /// generated feed. Returns a resolved absolute link to the file. pub fn has_static(&self, from: &impl LinkFrom, path: &str) -> Option<String> { // Attach parent if not an absolute path. // We don't want to canonicalise/sluggify the path. @@ -462,9 +462,14 @@ impl Website { true => collapse_path(&format!("{}{path}", from.parent_url())), false => collapse_path(path), }; + let root = from.root(); for file in &self.static_files { if file.url == path { - let root = from.root(); + return Some(format!("{root}{path}")); + } + } + for feed in &self.feeds { + if format!("{}.rss", feed.url) == path { return Some(format!("{root}{path}")); } } |
