rsshub
Version:
Make RSS Great Again!
105 lines (103 loc) • 2.86 kB
JavaScript
import { n as init_esm_shims, t as __dirname } from "./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 { t as ofetch_default } from "./ofetch-BIyrKU3Y.mjs";
import { t as parseDate } from "./parse-date-BrP7mxXf.mjs";
import { t as art } from "./render-BQo6B4tL.mjs";
import path from "node:path";
import { load } from "cheerio";
//#region lib/routes/windsurf/blog.ts
init_esm_shims();
const handler = async (ctx) => {
const limit = Number.parseInt(ctx.req.query("limit") ?? "10", 10);
const baseUrl = "https://windsurf.com";
const targetUrl = new URL("blog", baseUrl).href;
const apiUrl = new URL("api/blog", baseUrl).href;
const response = await ofetch_default(apiUrl, { query: {
paginate: limit,
cursor: 0
} });
const $ = load(await ofetch_default(targetUrl));
const language = $("html").attr("lang") ?? "en";
const title = $("title").first().text();
const author = title.split(/\|/).pop()?.trim();
const items = response.posts.slice(0, limit).map((item) => {
const title$1 = item.title;
const image = item.images?.[0];
const description = art(path.join(__dirname, "templates/description-881baa33.art"), {
images: image ? [{
src: image,
alt: title$1
}] : void 0,
intro: item.summary
});
const pubDate = item.date;
const linkUrl = item.slug;
const categories = item.tags;
const authors = item.authors.map((author$1) => ({
name: author$1,
url: void 0,
avatar: void 0
}));
const guid = item.slug ? `windsurf-blog-${item.slug}` : void 0;
const updated = pubDate;
return {
title: title$1,
description,
pubDate: pubDate ? parseDate(pubDate) : void 0,
link: linkUrl ? new URL(`blog/${linkUrl}`, baseUrl).href : void 0,
category: categories,
author: authors,
guid,
id: guid,
content: {
html: description,
text: description
},
image,
banner: image,
updated: updated ? parseDate(updated) : void 0,
language
};
});
return {
title,
description: $("meta[property=\"og:description\"]").attr("content"),
link: targetUrl,
item: items,
allowEmpty: true,
image: $("meta[property=\"og:image\"]").attr("content"),
author,
language,
id: $("meta[property=\"og:url\"]").attr("content")
};
};
const route = {
path: "/blog",
name: "Blog",
url: "windsurf.com",
maintainers: ["nczitzk"],
handler,
example: "/windsurf/blog",
parameters: void 0,
description: void 0,
categories: ["programming"],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: true,
supportBT: false,
supportPodcast: false,
supportScihub: false
},
radar: [{
source: ["windsurf.com/blog"],
target: "/blog"
}],
view: ViewType.Articles
};
//#endregion
export { handler, route };