| 418 | } |
| 419 | Ok(()) |
| 420 | } |
| 421 | |
| 422 | fn push_doc(collection: &str, path: &Path, slug: String, out: &mut Vec<DocOut>) -> io::Result<()> { |
| 423 | push_doc_with_link_slug(collection, path, slug.clone(), slug, out) |
| 424 | } |
| 425 | |
| 426 | fn push_doc_with_link_slug( |
| 427 | collection: &str, |
| 428 | path: &Path, |
| 429 | slug: String, |
| 430 | link_slug: String, |
| 431 | out: &mut Vec<DocOut>, |
| 432 | ) -> io::Result<()> { |
| 433 | let raw_markdown = fs::read_to_string(path)?; |
| 434 | let markdown = rewrite_markdown_links(collection, &link_slug, &raw_markdown); |
| 435 | let title = first_title(&markdown).unwrap_or_else(|| title_from_slug(&slug)); |
| 436 | let area = if collection == "book" { |
| 437 | "book".to_string() |
| 438 | } else { |
| 439 | slug.split('/').next().unwrap_or("docs").to_string() |
| 440 | }; |
| 441 | let is_history = is_history_page(collection, &slug); |
| 442 | let nav_group = nav_group(collection, &slug, is_history).to_string(); |
| 443 | let route_path = route_path(collection, &slug); |
| 444 | let summary = first_para(&markdown); |
| 445 | let headings = headings(&markdown); |
| 446 | let html = markdown_html(&markdown); |
| 447 | let keywords = doc_keywords(&slug, &title, &area, &summary, &headings); |
| 448 | let search_text = search_text(&slug, &title, &summary, &headings, &markdown); |
| 449 | out.push(DocOut { |
| 450 | collection: collection.to_string(), |
| 451 | slug, |
| 452 | route_path, |
| 453 | title, |
| 454 | area, |
| 455 | nav_group, |