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.

index.rs 935B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. use std::path::Path;
  2. use errors::Result;
  3. use site::Site;
  4. //use crate::console;
  5. pub fn index(
  6. root_dir: &Path,
  7. config_file: &str,
  8. base_url: Option<&str>,
  9. output_dir: &str,
  10. include_drafts: bool,
  11. index_type: &str,
  12. ) -> Result<()> {
  13. let mut site = Site::new(root_dir, config_file)?;
  14. site.set_output_path(output_dir);
  15. // TODO: is base_url even necessary for this command?
  16. if let Some(b) = base_url {
  17. site.set_base_url(b.to_string());
  18. }
  19. if include_drafts {
  20. site.include_drafts();
  21. }
  22. site.load()?;
  23. // TODO: could skipping the theme and/or sass prep end up
  24. // somehow impacting the search indexing? doesn't seem like
  25. // it could, but maybe
  26. match index_type {
  27. "elasticlunr" => {
  28. site.build_search_index()?;
  29. }
  30. "tantivy" => {
  31. unimplemented!()
  32. }
  33. _ => unreachable!()
  34. }
  35. Ok(())
  36. }