Skip to content

Commit b05a264

Browse files
committed
Add star counts to featured/supporter/highlighted sites and fix dedup. Organize
1 parent 3dab67e commit b05a264

2 files changed

Lines changed: 72 additions & 21 deletions

File tree

docs/src/routes/docs/showcase/+page.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
# Showcase
99

10-
## Featured
11-
12-
<Showcase sites={featuredSites} />
13-
1410
## Supporters
1511

1612
<Showcase sites={supporterSites} />
1713

14+
## Featured
15+
16+
<Showcase sites={featuredSites} />
17+
1818
[Become a sponsor](https://github.com/techniq/layerchart?tab=readme-ov-file#sponsors)
1919

2020
## Popular

docs/src/routes/docs/showcase/dependency.remote.ts

Lines changed: 68 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ export type Dependent = {
1515
};
1616

1717
export const getDependents = prerender(async () => {
18-
1918
const featuredSites: Dependent[] = [
19+
{
20+
name: 'Zipline AI',
21+
description: 'Features, context and embeddings for real-time AI/ML',
22+
repourl: 'https://zipline.ai/',
23+
homepageurl: 'https://github.com/zipline-ai'
24+
},
2025
{
2126
name: 'Github Analysis',
2227
description: 'Analyze your GitHub repositories and NPM packages',
@@ -28,12 +33,6 @@ export const getDependents = prerender(async () => {
2833
description: 'Analyze your Strava activities',
2934
repourl: 'https://github.com/techniq/strava-analysis',
3035
homepageurl: 'https://strava.techniq.dev'
31-
},
32-
{
33-
name: 'Zipline AI',
34-
description: 'Features, context and embeddings for real-time AI/ML',
35-
repourl: 'https://zipline.ai/',
36-
homepageurl: 'https://github.com/zipline-ai'
3736
}
3837
];
3938

@@ -188,19 +187,71 @@ export const getDependents = prerender(async () => {
188187
console.log(
189188
`[getDependents] Step 2 - GraphQL details: ${((performance.now() - step2Start) / 1000).toFixed(2)}s (${dependents.length} repos, ${batchPromises.length} batches)`
190189
);
190+
191+
// Step 3: Fetch stars for manually-listed sites (featured, supporters, highlighted)
192+
const step3Start = performance.now();
193+
const manualSites = [...featuredSites, ...supporterSites, ...highlightedSites];
194+
const githubRepoPattern = /github\.com\/([^/]+)\/([^/]+)/;
195+
const manualSitesWithRepos = manualSites
196+
.map((site) => {
197+
const match = site.repourl?.match(githubRepoPattern);
198+
return match ? { site, owner: match[1], name: match[2] } : null;
199+
})
200+
.filter(Boolean) as { site: Dependent; owner: string; name: string }[];
201+
202+
if (manualSitesWithRepos.length > 0) {
203+
const fragments = manualSitesWithRepos
204+
.map(
205+
({ owner, name }, idx) =>
206+
`manual${idx}: repository(owner: ${JSON.stringify(owner)}, name: ${JSON.stringify(name)}) { stargazerCount }`
207+
)
208+
.join('\n');
209+
210+
try {
211+
const res = await fetch('https://api.github.com/graphql', {
212+
method: 'POST',
213+
headers: githubHeaders,
214+
body: JSON.stringify({ query: `{ ${fragments} }` })
215+
});
216+
if (res.ok) {
217+
const { data } = await res.json();
218+
if (data) {
219+
manualSitesWithRepos.forEach(({ site }, idx) => {
220+
const repo = data[`manual${idx}`];
221+
if (repo) {
222+
site.stars = repo.stargazerCount;
223+
}
224+
});
225+
}
226+
}
227+
} catch (e) {
228+
console.error('[getDependents] Failed to fetch stars for manual sites:', e);
229+
}
230+
}
231+
console.log(
232+
`[getDependents] Step 3 - Manual site stars: ${((performance.now() - step3Start) / 1000).toFixed(2)}s (${manualSitesWithRepos.length} repos)`
233+
);
234+
191235
console.log(`[getDependents] Total: ${((performance.now() - totalStart) / 1000).toFixed(2)}s`);
192236

193-
dependents
194-
.sort((a, b) => (b.stars ?? 0) - (a.stars ?? 0)) // Sort by stars descending
195-
.filter((d) => featuredSites.some((f) => f.reponame === d.reponame)) // Filter out any featured sites
196-
.filter((d) => supporterSites.some((s) => s.reponame === d.reponame)); // Filter out any supporter sites
197-
const popularSites = [
198-
...highlightedSites,
199-
...dependents.filter((d) => (d.stars ?? 0) >= POPULAR_STAR_THRESHOLD)
200-
];
201-
const otherSites = dependents.filter(
202-
(d) => (d.stars ?? 0) >= OTHER_STAR_THRESHOLD && (d.stars ?? 0) < POPULAR_STAR_THRESHOLD
237+
// Build a set of repo URLs and homepage URLs from manually-listed sites for deduplication
238+
const manualUrls = new Set(
239+
manualSites.flatMap((s) => [s.repourl, s.homepageurl].filter(Boolean))
203240
);
204241

242+
const filteredDependents = dependents
243+
.filter((d) => !manualUrls.has(d.repourl) && !manualUrls.has(d.homepageurl))
244+
.sort((a, b) => (b.stars ?? 0) - (a.stars ?? 0));
245+
246+
const popularSites = filteredDependents.filter(
247+
(d) => (d.stars ?? 0) >= POPULAR_STAR_THRESHOLD
248+
);
249+
const otherSites = [
250+
...filteredDependents.filter(
251+
(d) => (d.stars ?? 0) >= OTHER_STAR_THRESHOLD && (d.stars ?? 0) < POPULAR_STAR_THRESHOLD
252+
),
253+
...highlightedSites
254+
];
255+
205256
return { featuredSites, supporterSites, popularSites, otherSites };
206257
});

0 commit comments

Comments
 (0)