pub fn extract_scripts<'a>(
path: &Path,
content: &'a str,
) -> Result<Vec<ExtractedScript<'a>>, ExtractorError>Expand description
Extract scripts from a framework file, auto-detecting the framework by extension.
§Arguments
path- The file path (used to determine framework by extension)content- The file content
§Returns
A vector of extracted scripts, or an error if extraction fails.
§Supported Extensions
.astro- Astro components.svelte- Svelte components.vue- Vue Single File Components
§Example
use super::extractors::extract_scripts;
use std::path::Path;
let path = Path::new("component.astro");
let content = r#"---
const title = 'My Page'
---
<script>
console.log(title)
</script>"#;
let scripts = extract_scripts(path, content)?;
assert_eq!(scripts.len(), 2); // Frontmatter + script tag