Toutes les sources
GitHub Trending
Développement v1.0.0Trending repositories on GitHub
@codytseng #github #trending #programming
Configuration
| Nom | Clé | Type | Requis | Défaut | Description |
|---|---|---|---|---|---|
| Language | LANGUAGE | string | Non | — | Filter by programming language (e.g., javascript, python). Leave empty for all languages. |
Code source
version: 1.0.0
name: GitHub Trending
description: Trending repositories on GitHub
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
- github
- trending
- programming
config:
- key: LANGUAGE
name: Language
type: string
required: false
description: Filter by programming language (e.g., javascript, python). Leave empty for all languages. version: 1.0.0
name: GitHub Trending
description: Trending repositories on GitHub
author: codytseng
author_url: https://github.com/codytseng
category: Developer
tags:
- github
- trending
- programming
config:
- key: LANGUAGE
name: Language
type: string
required: false
description: Filter by programming language (e.g., javascript, python). Leave empty for all languages. import type { GlancewayAPI, SourceMethods } from "../../types";
export default (api: GlancewayAPI): SourceMethods => {
return {
async refresh() {
const language = api.config.get("LANGUAGE");
const since = new Date();
since.setDate(since.getDate() - 7);
const sinceStr = since.toISOString().split("T")[0];
let query = `created:>${sinceStr} stars:>5`;
if (language) {
query += ` language:${language}`;
}
const response = await api.fetch<{
items: Array<{
id: number;
full_name: string;
description: string | null;
html_url: string;
stargazers_count: number;
language: string | null;
}>;
}>(
`https://api.github.com/search/repositories?q=${encodeURIComponent(query)}&sort=stars&order=desc&per_page=30`,
);
if (!response.ok || !response.json) {
return;
}
api.emit(
response.json.items.map((repo) => {
return {
id: repo.id.toString(),
title: repo.full_name,
subtitle: repo.description || `${repo.language ?? "Unknown"} · ${repo.stargazers_count} stars`,
url: repo.html_url,
};
}),
);
},
};
}; import type { GlancewayAPI, SourceMethods } from "../../types";
export default (api: GlancewayAPI): SourceMethods => {
return {
async refresh() {
const language = api.config.get("LANGUAGE");
const since = new Date();
since.setDate(since.getDate() - 7);
const sinceStr = since.toISOString().split("T")[0];
let query = `created:>${sinceStr} stars:>5`;
if (language) {
query += ` language:${language}`;
}
const response = await api.fetch<{
items: Array<{
id: number;
full_name: string;
description: string | null;
html_url: string;
stargazers_count: number;
language: string | null;
}>;
}>(
`https://api.github.com/search/repositories?q=${encodeURIComponent(query)}&sort=stars&order=desc&per_page=30`,
);
if (!response.ok || !response.json) {
return;
}
api.emit(
response.json.items.map((repo) => {
return {
id: repo.id.toString(),
title: repo.full_name,
subtitle: repo.description || `${repo.language ?? "Unknown"} · ${repo.stargazers_count} stars`,
url: repo.html_url,
};
}),
);
},
};
};