59 lines
1.9 KiB
YAML
59 lines
1.9 KiB
YAML
site: github
|
|
name: trending
|
|
description: GitHub trending repositories
|
|
domain: github.com
|
|
|
|
args:
|
|
language:
|
|
type: str
|
|
default: ""
|
|
description: "Programming language filter (e.g. python, rust)"
|
|
since:
|
|
type: str
|
|
default: daily
|
|
description: "Time range: daily, weekly, monthly"
|
|
limit:
|
|
type: int
|
|
default: 20
|
|
description: Number of repos
|
|
|
|
pipeline:
|
|
- evaluate: |
|
|
(async () => {
|
|
const lang = '${{ args.language }}' ? '/${{ args.language }}' : '';
|
|
const res = await fetch(`https://github.com/trending${lang}?since=${{ args.since }}`, {
|
|
headers: { 'Accept': 'text/html' }
|
|
});
|
|
const html = await res.text();
|
|
const parser = new DOMParser();
|
|
const doc = parser.parseFromString(html, 'text/html');
|
|
const rows = doc.querySelectorAll('article.Box-row');
|
|
return Array.from(rows).map(row => {
|
|
const nameEl = row.querySelector('h2 a');
|
|
const descEl = row.querySelector('p');
|
|
const langEl = row.querySelector('[itemprop="programmingLanguage"]');
|
|
const starsEl = row.querySelectorAll('a.Link--muted');
|
|
const todayEl = row.querySelector('span.d-inline-block.float-sm-right');
|
|
return {
|
|
repo: nameEl?.textContent?.trim()?.replace(/\s+/g, '') || '',
|
|
description: descEl?.textContent?.trim() || '',
|
|
language: langEl?.textContent?.trim() || '',
|
|
stars: starsEl[0]?.textContent?.trim() || '',
|
|
forks: starsEl[1]?.textContent?.trim() || '',
|
|
today: todayEl?.textContent?.trim() || ''
|
|
};
|
|
});
|
|
})()
|
|
|
|
- map:
|
|
rank: ${{ index + 1 }}
|
|
repo: ${{ item.repo }}
|
|
description: ${{ item.description }}
|
|
language: ${{ item.language }}
|
|
stars: ${{ item.stars }}
|
|
today: ${{ item.today }}
|
|
|
|
- limit: ${{ args.limit }}
|
|
|
|
columns: [rank, repo, language, stars, today]
|