Files
RSSHub/lib/routes/obsidian/plugins.ts
T
Tony b84bb92a8a style: replace unicorn/no-for-loop w/ typescript/prefer-for-of (#20798)
* style: replace unicorn/no-for-loop w/ typescript/prefer-for-of

* style: fix typescript-eslint/prefer-for-of

* style: fix typescript/no-inferrable-types

* style: fix typescript-eslint/consistent-generic-constructors

* style: typescript-eslint/consistent-type-assertions

* style: fix typescript-eslint/array-type

* fix: revert .entries() in d96ca62d3d80806b0475a54e749decfc07b24701
2026-01-02 09:42:24 +08:00

41 lines
1.3 KiB
TypeScript

import type { Route } from '@/types';
import ofetch from '@/utils/ofetch';
export const route: Route = {
path: '/plugins',
name: 'Obsidian Plugins',
maintainers: ['DIYgod'],
categories: ['program-update'],
example: '/obsidian/plugins',
handler,
};
async function handler() {
const data = JSON.parse(await ofetch('https://raw.githubusercontent.com/obsidianmd/obsidian-releases/refs/heads/master/community-plugins.json')) as Array<{
id: string;
name: string;
author: string;
description: string;
repo: string;
}>;
const stats = JSON.parse(await ofetch('https://raw.githubusercontent.com/obsidianmd/obsidian-releases/HEAD/community-plugin-stats.json')) as {
[key: string]: {
downloads: number;
updated: number;
};
};
return {
title: 'Obsidian Plugins',
link: `https://obsidian.md/plugins`,
item: data.map((item) => ({
title: item.name,
description: `${item.description}<br><br>Downloads: ${stats[item.id].downloads}`,
link: `https://github.com/${item.repo}`,
guid: item.id,
pubDate: new Date(stats[item.id].updated),
author: item.author,
})),
};
}