Browse Source

More early tera fns and mention limitation of shortcodes in docs

index-subcmd
Vincent Prouillet 5 years ago
parent
commit
1b4cfd49d0
2 changed files with 9 additions and 5 deletions
  1. +5
    -5
      components/site/src/lib.rs
  2. +4
    -0
      docs/content/documentation/content/shortcodes.md

+ 5
- 5
components/site/src/lib.rs View File

@@ -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


+ 4
- 0
docs/content/documentation/content/shortcodes.md View File

@@ -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 `<a>` or `<span>` 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:


Loading…
Cancel
Save