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.

42 lines
1.0KB

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