UNPKG

rsshub

Version:
74 lines (72 loc) 2.04 kB
import "./esm-shims-CzJ_djXG.mjs"; import "./config-C37vj7VH.mjs"; import { t as ViewType } from "./types-D84BRIt4.mjs"; import "./dist-BInvbO1W.mjs"; import "./logger-Czu8UMNd.mjs"; import "./ofetch-BIyrKU3Y.mjs"; import "./parse-date-BrP7mxXf.mjs"; import { n as processWithWp, r as rootUrl, t as extractMiniCards } from "./utils-CTLBp6NJ.mjs"; //#region lib/routes/css-tricks/collections.ts const route = { path: "/collections/:type", view: ViewType.Articles, categories: ["programming"], example: "/css-tricks/collections/2", parameters: { category: { description: "Collection Type", options: [ { value: "3", label: "Latest CSS Guides" }, { value: "2", label: "Fresh From the Almanac" }, { value: "4", label: "Classic Tricks" } ] } }, features: { requireConfig: false, requirePuppeteer: false, antiCrawler: false, supportBT: false, supportPodcast: false, supportScihub: false }, radar: [{ source: ["css-tricks.com"], target: "/collections/:type" }], name: "CSS Guides", maintainers: ["Rjnishant530"], handler }; const WPTYPE = { "2": "pages", "3": "posts", "4": "chapters" }; async function handler(ctx) { const paramType = ctx.req.param("type"); const type = paramType === "1" ? "2" : paramType; const baseSelector = `body > div.page-wrap > section.post-sliders > div:nth-child(${type})`; const titleSelector = `${baseSelector}>div.post-slider-header.header-card > h2`; const descSelector = `${baseSelector}>div.post-slider-header.header-card > p`; const { title, description, cards } = await extractMiniCards(`${baseSelector} article.mini-card.module.module-article`, titleSelector, descSelector); const items = await processWithWp(cards, true, WPTYPE[type]); return { title: title || "Fresh From the Almanac", description: description || "Properties, selectors, rules, and functions!", link: rootUrl, item: items, language: "en", logo: `${rootUrl}/favicon.ico`, icon: `${rootUrl}/favicon.ico` }; } //#endregion export { route };