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.

43 lines
1.1KB

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