Skip to main content

write_agents_txt

Function write_agents_txt 

Source
pub fn write_agents_txt(
    ctx: &PluginContext,
    agents: &AgentsConfig,
) -> Result<(), SsgError>
Expand description

Render and write the agents.txt file under ctx.site_dir.

§Errors

Returns SsgError::Io if agents.txt cannot be written (e.g. the site directory is read-only or full).

§Examples

use ssg::plugin::PluginContext;
use ssg::postprocess::agentic_discovery::{AgentsConfig, write_agents_txt};
use std::fs;
let tmp = tempfile::tempdir().unwrap();
let ctx = PluginContext::new(tmp.path(), tmp.path(), tmp.path(), tmp.path());
let cfg = AgentsConfig::default();
write_agents_txt(&ctx, &cfg).unwrap();
let body = fs::read_to_string(tmp.path().join("agents.txt")).unwrap();
assert!(body.contains("User-agent: *"));