import{t as e}from"./cache-DUthuMSu.mjs";import{t}from"./parse-date-BdYTmLpo.mjs";import{t as n}from"./got-BBDj7u1e.mjs";import{load as r}from"cheerio";const i={path:`/:category?`,categories:[`new-media`],example:`/newsmarket`,parameters:{category:`分类，见下表，默认为首页`},features:{requireConfig:!1,requirePuppeteer:!1,antiCrawler:!1,supportBT:!1,supportPodcast:!1,supportScihub:!1},radar:[{source:[`newsmarket.com.tw/blog/category/:category`,`newsmarket.com.tw/`]}],name:`分類`,maintainers:[`nczitzk`],handler:a,description:`| 時事。政策  | 食安        | 新知      | 愛地方       | 種好田       | 好吃。好玩    |
| ----------- | ----------- | --------- | ------------ | ------------ | ------------- |
| news-policy | food-safety | knowledge | country-life | good-farming | good-food-fun |

| 食農教育       | 人物               | 漁業。畜牧           | 綠生活。國際        | 評論    |
| -------------- | ------------------ | -------------------- | ------------------- | ------- |
| food-education | people-and-history | raising-and-breeding | living-green-travel | opinion |`};async function a(i){let a=i.req.param(`category`)??``,o=`https://www.newsmarket.com.tw${a?`/blog/category/${a}`:``}`,s=r((await n({method:`get`,url:o})).data),c=s(`.title a`).slice(0,i.req.query(`limit`)?Number.parseInt(i.req.query(`limit`)):20).toArray().map(e=>(e=s(e),{title:e.text(),link:e.attr(`href`),pubDate:t()})),l=await Promise.all(c.map(i=>e.tryGet(i.link,async()=>{let e=await n({method:`get`,url:i.link}),a=r(e.data);return a(`figure img`).each(function(){a(this).parent().html(`<img src="${a(this).attr(`data-src`)}">`)}),a(`.inline-post`).remove(),i.author=a(`.author-name`).text(),i.description=a(`.entry-content`).html(),i.pubDate=t(e.data.match(/"datePublished":"(.*)","dateModified"/)[1]),i})));return{title:s(`title`).text(),link:o,item:l}}export{i as route};