Commit 51ef0df
authored
feat(route): add 国际能源网 (in-en.com) news route (#21669)
* feat(route): add 国际能源网 (in-en.com) news route
Add RSS route for in-en.com (国际能源网), a major Chinese energy news portal.
Supported channels via /in-en/news/:type:
- solar — 光伏太阳能
- wind — 风电
- chuneng — 储能
- h2 — 氢能
- chd — 充换电
- newenergy — 新能源综合
- power — 电力
- huanbao — 环保
Features: fetches article list from each subdomain's news page,
then retrieves full article body via detail page (cached).
Handles Chinese relative timestamps (X分钟/小时/天前).
* fix(in-en): add maintainer, fix timezone double-shift, translate comments to English
* fix(in-en): correct news paths for h2/chd/huanbao, drop date-only pubDate override
* fix(in-en): sort imports, fix numeric separators, add category field, use trueUA
* fix(in-en): address review comments
- Remove config.trueUA, use default UA
- Remove custom parseRelTime, use parseDate directly
- Fix title text extraction without cloning element
- Remove unnecessary .first() on pubDate
- Fix author: handle both em.ly and plain-text source via .prompt > span
- Simplify category field (remove redundant length check)
- Fix description selector: .article-body → #article
- Fix detail author selector: .article-meta .source a → p.source a
- Remove try-catch around detail fetch
* fix(in-en): fix author including category text and handle relative pubDate formats
* fix(in-en): use parseRelativeDate, simplify selectors, drop redundant fallbacks
- Replace hand-rolled relative-date logic with parseRelativeDate (covers
"刚刚 / N分钟前 / N小时前 / 今天 HH:MM / 昨天 HH:MM / YYYY-MM-DD"). Fixes
Invalid Date on the first few entries and resolves the two oxlint findings
(no-useless-undefined, numeric-separators-style).
- Drop the `.first()` on `.listTxt .prompt i` — each `ul.infoList > li` carries
exactly one `<i>` (date), confirmed against https://solar.in-en.com/news/.
- Author selector: `.prompt > span:first-of-type`, then strip leading "来源:".
Cheerio's `.text()` flattens `<em class="ly">…</em>` into the same string,
so this matches both shapes shown on https://solar.in-en.com/news/
(plain text vs. wrapped in em.ly).
- Category selector: `.prompt > span:not(:first-of-type) em a`, scoped to the
second span so author text never leaks in.
- Drop `|| undefined` on author and `?? ''` on description (redundant —
DataItem already accepts undefined).
- Add an HTML-shape comment pointing to the live sample URL so future
reviewers can verify the layout assumptions.
* fix(in-en): drop dead default + use new-media category
- Hono treats `:type` as compulsory (path is `/news/:type`), so users without
it never reach the handler — the `?? 'solar'` fallback was unreachable.
Replace with a non-null assertion to keep the type narrow.
- categories: 'traditional-media' → 'new-media' per review suggestion.1 parent 63157fb commit 51ef0df
2 files changed
Lines changed: 123 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
0 commit comments