Skip to content

Commit

Permalink
Add url field to books
Browse files Browse the repository at this point in the history
  • Loading branch information
bahlo committed Nov 3, 2024
1 parent 80767a1 commit 1923b21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/arneos/src/content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub struct Book {
pub read: NaiveDate,
pub rating: u8,
pub location: String,
pub url: Option<Url>,
pub excerpt_html: String,
pub content_html: String,
}
Expand Down Expand Up @@ -502,6 +503,7 @@ impl Content {
pub read: NaiveDate,
pub rating: u8,
pub location: String,
pub url: Option<Url>,
}

let markdown = matter.parse(&contents);
Expand Down Expand Up @@ -543,6 +545,7 @@ impl Content {
read: frontmatter.read,
rating: frontmatter.rating,
location: smart_quotes(frontmatter.location),
url: frontmatter.url,
excerpt_html,
content_html,
});
Expand Down
4 changes: 4 additions & 0 deletions crates/ssg/src/templates/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ pub fn render(book: &Book) -> Result<Context> {
(PreEscaped(" &middot; "))
(book.rating)
"/5"
@if let Some(url) = &book.url {
(PreEscaped(" &middot; "))
a href=(url) { "Buy" }
}
}
}
picture {
Expand Down

0 comments on commit 1923b21

Please sign in to comment.