github stopped doing ssr for readmes
This commit is contained in:
parent
bfec2d8d87
commit
134cba4061
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -421,7 +421,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "fend-core"
|
name = "fend-core"
|
||||||
version = "1.4.1"
|
version = "1.4.1"
|
||||||
source = "git+https://github.com/mat-1/fend?branch=main#5c48b97070bbb6b1ec52400b2547e6f369cd78c7"
|
source = "git+https://github.com/printfn/fend?branch=main#5e5080231a5c22814ff778d3a1b4577467dd2ccd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
|
@ -40,4 +40,5 @@ url = "2.5.0"
|
|||||||
urlencoding = "2.1.3"
|
urlencoding = "2.1.3"
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
fend-core = { git = "https://github.com/mat-1/fend", branch = "main" }
|
# temporarily using git version of fend-core since it adds codepoint to character conversion
|
||||||
|
fend-core = { git = "https://github.com/printfn/fend", branch = "main" }
|
||||||
|
@ -26,8 +26,20 @@ pub fn parse_response(body: &str) -> Option<String> {
|
|||||||
.attr("href")?;
|
.attr("href")?;
|
||||||
let url = format!("https://github.com{url_relative}");
|
let url = format!("https://github.com{url_relative}");
|
||||||
|
|
||||||
let readme = dom.select(&Selector::parse("article").unwrap()).next()?;
|
let embedded_data_script = dom
|
||||||
let readme_html = readme.inner_html().trim().to_string();
|
.select(&Selector::parse("script[data-target='react-partial.embeddedData']").unwrap())
|
||||||
|
.last()?
|
||||||
|
.inner_html();
|
||||||
|
let embedded_data = serde_json::from_str::<serde_json::Value>(&embedded_data_script).ok()?;
|
||||||
|
let readme_html = embedded_data
|
||||||
|
.get("props")?
|
||||||
|
.get("initialPayload")?
|
||||||
|
.get("overview")?
|
||||||
|
.get("overviewFiles")?
|
||||||
|
.as_array()?
|
||||||
|
.first()?
|
||||||
|
.get("richText")?
|
||||||
|
.as_str()?;
|
||||||
|
|
||||||
let mut readme_html = ammonia::Builder::default()
|
let mut readme_html = ammonia::Builder::default()
|
||||||
.link_rel(None)
|
.link_rel(None)
|
||||||
|
Loading…
Reference in New Issue
Block a user