Skip to content

Commit

Permalink
feat: add obsidian plugins route
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Dec 23, 2024
1 parent db9d5ce commit 9175f05
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions lib/routes/obsidian/plugins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { 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 {
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,
})),
};
}

0 comments on commit 9175f05

Please sign in to comment.