rsshub
Version:
Make RSS Great Again!
45 lines (44 loc) • 1.47 kB
JavaScript
import { t as rofetch } from "./ofetch-U0CdpE2g.mjs";
import { t as parseDate } from "./parse-date-3kcy2Eau.mjs";
import { t as cache_default } from "./cache-C1Y-9qDV.mjs";
import { t as timezone } from "./timezone-UiMFOuvL.mjs";
import { load } from "cheerio";
//#region lib/routes/gov/mnd/index.ts
const route = {
path: "/",
categories: ["government"],
example: "/gov/mnd",
radar: [{ source: ["www.mnd.gov.tw/newslist"] }],
name: "即時軍事動態",
maintainers: ["nczitzk"],
handler,
url: "www.mnd.gov.tw/newslist"
};
async function handler() {
const rootUrl = "https://www.mnd.gov.tw";
const link = `${rootUrl}/newslist`;
const response = await rofetch(link);
const $ = load(response);
const list = $("a.news_list").toArray().map((item) => {
const $item = $(item);
const dateSplit = $item.find(".date").text().split(".");
dateSplit[0] = (Number.parseInt(dateSplit[0]) + 1911).toString();
return {
title: $item.find(".title").text(),
link: new URL($item.attr("href"), rootUrl).href,
pubDate: timezone(parseDate(dateSplit.join("-")), 8),
category: [$item.find(".category").text()]
};
});
return {
title: "即時軍事動態 - 中華民國國防部",
link,
item: await Promise.all(list.map((item) => cache_default.tryGet(item.link, async () => {
const detailResponse = await rofetch(item.link);
item.description = load(detailResponse)("div.maincontent").html();
return item;
})))
};
}
//#endregion
export { route };