···158158 /// that all content sources should be re-initialized.
159159 ///
160160 /// Only considers files that look like content files (have common content extensions).
161161- pub fn get_affected_content_sources(&self, changed_files: &[PathBuf]) -> Option<FxHashSet<String>> {
161161+ pub fn get_affected_content_sources(
162162+ &self,
163163+ changed_files: &[PathBuf],
164164+ ) -> Option<FxHashSet<String>> {
162165 let content_extensions = ["md", "mdx", "yaml", "yml", "json", "toml"];
163166 let mut affected_sources = FxHashSet::default();
164167···9991002 state.track_content_file_source(file.clone(), "articles".to_string());
1000100310011004 assert_eq!(state.content_file_to_source.len(), 1);
10021002- assert_eq!(state.content_file_to_source.get(&file), Some(&"articles".to_string()));
10051005+ assert_eq!(
10061006+ state.content_file_to_source.get(&file),
10071007+ Some(&"articles".to_string())
10081008+ );
10031009 }
1004101010051011 #[test]
···10271033 state.track_content_file_source(page.clone(), "pages".to_string());
1028103410291035 // Change both files
10301030- let affected = state.get_affected_content_sources(&[article, page]).unwrap();
10361036+ let affected = state
10371037+ .get_affected_content_sources(&[article, page])
10381038+ .unwrap();
10311039 assert_eq!(affected.len(), 2);
10321040 assert!(affected.contains("articles"));
10331041 assert!(affected.contains("pages"));
···10571065 let rust_file = PathBuf::from("/project/src/pages/index.rs");
1058106610591067 // Should return empty set (no content sources affected)
10601060- let affected = state.get_affected_content_sources(&[rust_file.clone()]).unwrap();
10681068+ let affected = state
10691069+ .get_affected_content_sources(std::slice::from_ref(&rust_file))
10701070+ .unwrap();
10611071 assert!(affected.is_empty());
1062107210631073 // Mixed: content file + non-content file
10641064- let affected = state.get_affected_content_sources(&[article, rust_file]).unwrap();
10741074+ let affected = state
10751075+ .get_affected_content_sources(&[article, rust_file])
10761076+ .unwrap();
10651077 assert_eq!(affected.len(), 1);
10661078 assert!(affected.contains("articles"));
10671079 }
···10961108 // Articles source mappings should be removed
10971109 assert!(!state.content_file_to_source.contains_key(&article1));
10981110 assert!(!state.content_file_to_source.contains_key(&article2));
10991099-11111111+11001112 // But routes mappings should be preserved (cleared separately per-route)
11011113 assert!(state.content_file_to_routes.contains_key(&article1));
11021114 assert!(state.content_file_to_routes.contains_key(&article2));
···11041116 // Pages should remain completely unchanged
11051117 assert!(state.content_file_to_source.contains_key(&page));
11061118 assert!(state.content_file_to_routes.contains_key(&page));
11071107- assert_eq!(state.content_file_to_source.get(&page), Some(&"pages".to_string()));
11191119+ assert_eq!(
11201120+ state.content_file_to_source.get(&page),
11211121+ Some(&"pages".to_string())
11221122+ );
11081123 }
1109112411101125 #[test]
+12-6
crates/maudit/src/content.rs
···11//! Core functions and structs to define the content sources of your website.
22//!
33//! Content sources represent the content of your website, such as articles, blog posts, etc. Then, content sources can be passed to [`coronate()`](crate::coronate), through the [`content_sources!`](crate::content_sources) macro, to be loaded.
44-use std::{any::Any, cell::RefCell, path::PathBuf, sync::Arc};
44+use std::{
55+ any::Any,
66+ cell::RefCell,
77+ path::{Path, PathBuf},
88+ sync::Arc,
99+};
510611use rustc_hash::{FxHashMap, FxHashSet};
712···50555156/// Record that a content file was accessed.
5257/// This is called internally when entries are accessed.
5353-fn track_content_file_access(file_path: &PathBuf) {
5858+fn track_content_file_access(file_path: &Path) {
5459 ACCESSED_CONTENT_FILES.with(|cell| {
5560 if let Some(ref mut set) = *cell.borrow_mut() {
5656- set.insert(file_path.clone());
6161+ set.insert(file_path.to_path_buf());
5762 }
5863 });
5964}
···419424420425 // Track file access for incremental builds
421426 if let Some(entry) = &entry
422422- && let Some(ref file_path) = entry.file_path {
423423- track_content_file_access(file_path);
424424- }
427427+ && let Some(ref file_path) = entry.file_path
428428+ {
429429+ track_content_file_access(file_path);
430430+ }
425431426432 entry
427433 }