Skip to content

Commit

Permalink
Include authors and a link to the book on the book page
Browse files Browse the repository at this point in the history
  • Loading branch information
Coi-l committed Mar 26, 2024
1 parent bc444c8 commit 5c179b6
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/cmd/shelf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ fn process_book(
book.config.book.shelf_url = Some(shelf_url.to_path_buf());
book.build()?;

// Create post in index file
let title = book.config.book.title.unwrap_or_default();
writeln!(
index_file,
"## [{title}](<../../{BOOKS_DIR}/{title}/{INDEX_HTML_FILE}>)"
)?;
let book_link = format!("## [{title}](<../../{BOOKS_DIR}/{title}/{INDEX_HTML_FILE}>)");

// Create post in index file
writeln!(index_file, "{book_link}")?;
writeln!(index_file)?;
let desc = book.config.book.description.unwrap_or_default();
writeln!(index_file, "{desc}")?;
Expand All @@ -58,9 +57,13 @@ fn process_book(
let mut file_path = shelf_source.clone();
file_path.push(&file_name);
let mut bf = File::create(file_path)?;
writeln!(bf, "# {title}")?;
writeln!(bf, "{book_link}")?;
writeln!(bf)?;
writeln!(bf, "{desc}")?;
writeln!(bf)?;
writeln!(bf)?;
let authors = book.config.book.authors.join(", ");
writeln!(bf, "*{authors}*")?;

// Add the chapter to the summary
writeln!(summary, "- [{title}](./{file_name})")?;
Expand Down

0 comments on commit 5c179b6

Please sign in to comment.