From 91131a7e3675541e7e65d249f7b91cd421f239f4 Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Sat, 28 Jun 2025 00:38:33 +0800 Subject: [PATCH] fix(route): add pdf files of nidc papers (#19478) --- lib/routes/nifd/research.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/routes/nifd/research.ts b/lib/routes/nifd/research.ts index 80f307a8f..9759210eb 100644 --- a/lib/routes/nifd/research.ts +++ b/lib/routes/nifd/research.ts @@ -62,6 +62,22 @@ async function handler(ctx) { const content = load(detailResponse.data); item.description = content('div.qrd-content').html(); + const $enclosureEl = content('div.report-bottom a').first(); + const enclosureUrl = $enclosureEl.attr('href'); + + if (enclosureUrl) { + const enclosureItem = { + enclosure_url: new URL(enclosureUrl, rootUrl).href, + enclosure_type: `application/${enclosureUrl.split(/\./).pop() ?? 'pdf'}`, + enclosure_title: $enclosureEl.prev().text(), + }; + + item = { + ...item, + ...enclosureItem, + }; + } + return item; }) )