diff --git a/example/src/f/a.md b/example/src/f/a.md index 13db437..c12fac7 100644 --- a/example/src/f/a.md +++ b/example/src/f/a.md @@ -7,3 +7,4 @@ This is a nested example +![](/a/mdbook-typst-doc/525af.svg) \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index 8859d18..0dfa24c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -58,6 +58,7 @@ pub struct Config<'a> { pub root: Option, pub src: String, pub cache: String, + pub url: String, pub handlebars: Handlebars<'a>, } @@ -83,6 +84,7 @@ impl<'a> Default for Config<'a> { root: None, src: String::new(), cache: String::new(), + url: String::new(), handlebars: hb, } } @@ -120,6 +122,10 @@ impl<'a> Config<'a> { ..Default::default() }; + if let Some(html_config) = config.html_config() { + cfg.url = html_config.site_url.unwrap_or_default() + &cfg.src; + } + if !Path::new(&cfg.cache).exists() { fs::create_dir(&cfg.cache)?; } diff --git a/src/lib.rs b/src/lib.rs index e790c50..a543b30 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -170,7 +170,7 @@ impl TypstPreprocessor { sender.send(child).unwrap(); } - data.insert("image", format!("![]({}/{name})", &config.cache)); + data.insert("image", format!("![]({}/{name})", &config.url)); } config .handlebars