From 5c179b6bca36d3f222cfdbc17e62246e46fd4209 Mon Sep 17 00:00:00 2001 From: Coil Date: Tue, 26 Mar 2024 17:42:36 +0100 Subject: [PATCH] Include authors and a link to the book on the book page --- src/cmd/shelf.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cmd/shelf.rs b/src/cmd/shelf.rs index e49de2d113..adf788a955 100644 --- a/src/cmd/shelf.rs +++ b/src/cmd/shelf.rs @@ -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}")?; @@ -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})")?;