You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1003B

  1. use std::collections::HashMap;
  2. use tera::{Tera, Context};
  3. use front_matter::InsertAnchor;
  4. use config::Config;
  5. /// All the information from the gutenberg site that is needed to render HTML from markdown
  6. #[derive(Debug)]
  7. pub struct RenderContext<'a> {
  8. pub tera: &'a Tera,
  9. pub config: &'a Config,
  10. pub teracontext: Context,
  11. pub current_page_permalink: &'a str,
  12. pub permalinks: &'a HashMap<String, String>,
  13. pub insert_anchor: InsertAnchor,
  14. }
  15. impl<'a> RenderContext<'a> {
  16. pub fn new(
  17. tera: &'a Tera,
  18. config: &'a Config,
  19. current_page_permalink: &'a str,
  20. permalinks: &'a HashMap<String, String>,
  21. insert_anchor: InsertAnchor,
  22. ) -> RenderContext<'a> {
  23. let mut teracontext = Context::new();
  24. teracontext.insert("config", config);
  25. RenderContext {
  26. tera,
  27. teracontext,
  28. current_page_permalink,
  29. permalinks,
  30. insert_anchor,
  31. config,
  32. }
  33. }
  34. }