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)] #[derive(Serialize, Debug, Clone)]
pub struct CrateInfo { pub struct CrateInfo {
pub name: String, pub name: String,
pub description: String, pub description: Option<String>,
pub owner: String, pub owner: String,
pub latest_version: Version, pub latest_version: Version,
pub versions: Vec<Version>, pub versions: Vec<Version>,

View File

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

View File

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