diff --git a/components/site/src/lib.rs b/components/site/src/lib.rs index bffc3fe..5c3a98f 100644 --- a/components/site/src/lib.rs +++ b/components/site/src/lib.rs @@ -339,20 +339,20 @@ impl Site { "load_data", global_fns::make_load_data(self.content_path.clone(), self.base_path.clone()), ); + self.tera.register_function("trans", global_fns::make_trans(self.config.clone())); + self.tera.register_function( + "get_taxonomy_url", + global_fns::make_get_taxonomy_url(&self.taxonomies), + ); } pub fn register_tera_global_fns(&mut self) { - self.tera.register_function("trans", global_fns::make_trans(self.config.clone())); self.tera.register_function("get_page", global_fns::make_get_page(&self.library)); self.tera.register_function("get_section", global_fns::make_get_section(&self.library)); self.tera.register_function( "get_taxonomy", global_fns::make_get_taxonomy(&self.taxonomies, &self.library), ); - self.tera.register_function( - "get_taxonomy_url", - global_fns::make_get_taxonomy_url(&self.taxonomies), - ); } /// Add a page to the site diff --git a/docs/content/documentation/content/shortcodes.md b/docs/content/documentation/content/shortcodes.md index edcdbc6..290c2c3 100644 --- a/docs/content/documentation/content/shortcodes.md +++ b/docs/content/documentation/content/shortcodes.md @@ -36,6 +36,10 @@ That's it, Zola will now recognise this template as a shortcode named `youtube` The markdown renderer will wrap an inline HTML node like `` or `` into a paragraph. If you want to disable that, simply wrap your shortcode in a `div`. +Shortcodes are rendered before parsing the markdown so it doesn't have access to the table of contents. Because of that, +you also cannot use the `get_page`/`get_section`/`get_taxonomy` global function. It might work while running `zola serve` because +it has been loaded but it will fail during `zola build`. + ## Using shortcodes There are two kinds of shortcodes: