Do optional the crate description

main
kirbylife 2024-10-02 19:06:13 -06:00
parent d65343d912
commit beead99db8
3 changed files with 4 additions and 6 deletions

View File

@ -4,7 +4,7 @@ use serde::Serialize;
#[derive(Serialize, Debug, Clone)]
pub struct CrateInfo {
pub name: String,
pub description: String,
pub description: Option<String>,
pub owner: String,
pub latest_version: Version,
pub versions: Vec<Version>,

View File

@ -106,11 +106,7 @@ pub fn search_crate(crate_name: String) -> Option<CrateInfo> {
} else {
let description = resp
.css_once(".desc")
.unwrap()
.content()
.trim()
.replace('\n', " ")
.into();
.map(|desc| desc.content().trim().replace("\n", " ").into());
let owner = resp
.css("a.owner")
.iter()

View File

@ -7,7 +7,9 @@
{%- if item -%}
## {{ item.name }} v{{ item.latest_version.version }}
{% if item.description -%}
> {{ item.description }}
{%- endif %}
by {{ item.owner }} {% if item.license %}[{{ item.license }}]{% endif %}
### Install by: