Skip to content

Commit f0d90f7

Browse files
committed
prepare for IndexNow
1 parent be16380 commit f0d90f7

File tree

24 files changed

+123
-138
lines changed

24 files changed

+123
-138
lines changed

app/app.consts.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { RANK_NAME } from '@/badge/badge.consts';
2+
13
// Must be 7 categories
24
export const TIER_NAMES = ['Beginner', 'Adept', 'Advanced', 'Expert', 'Master', 'Elite', 'Legend'] as const;
35
// duplicated from api
@@ -11,21 +13,21 @@ export const NOT_AVAILABLE = `Tiers are available for rankings with over ${MIN_P
1113

1214
export const RANK_DESCRIPTIONS = {
1315
s: {
14-
title: 'Stars rank',
16+
title: RANK_NAME.s,
1517
descriptionList: `Rank is based on the total number of stars across repositories owned by a user.`,
1618
descriptionProfile: `Counts stars on repositories owned by the profile. The ranking includes only profiles that have at least one repository with ${MIN_VALUE}+ stars.`,
1719
entityName: 'star',
1820
notRankedMessage: `A profile must own at least one repository with ${MIN_VALUE}+ stars to be ranked.`,
1921
},
2022
c: {
21-
title: 'Contributor rank',
23+
title: RANK_NAME.c,
2224
descriptionList: 'Ranks count stars from repos where a developer has merged PRs — excluding their own.',
2325
descriptionProfile: `Counts stars on repos owned by others with merged PRs from this profile. Listed only if it has contributed to at least one repo with ${MIN_VALUE}+ stars.`,
2426
entityName: 'star',
2527
notRankedMessage: `Profiles need a merged PR in a repo with ${MIN_VALUE}+ stars to be ranked.`,
2628
},
2729
f: {
28-
title: 'Followers rank',
30+
title: RANK_NAME.f,
2931
descriptionList: 'Rank is based on the number of followers the user has on GitHub.',
3032
descriptionProfile: `Counts users who follow this profile. The ranking includes only profiles that have ${MIN_VALUE}+ followers.`,
3133
entityName: 'follower',

app/badge/builder/[[...login]]/components/badge-form.tsx

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ import { useForm } from 'react-hook-form';
77
import { useDebounceCallback } from 'usehooks-ts';
88
import { z } from 'zod';
99

10+
import { RANK_NAME } from '@/badge/badge.consts';
1011
import { BadgeNuqsSchema } from '@/badge/badge.nuqs';
1112
import { BadgeV2ZodSchema } from '@/badge/badge.zod';
1213
import { LABEL_BG, VALUE_BG } from '@/badge/templates/inline/inline.consts';
1314
import { Form, FormControl, FormField, FormItem, FormLabel } from '@/components/ui/form';
1415
import { Input } from '@/components/ui/input';
1516
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
1617
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
17-
import { BadgeContext, BadgeCornerStyle, BadgeMeta, BadgeRanking, BadgeType } from '@/types/badge.types';
18+
import { BadgeContext, BadgeCornerStyle, BadgeMeta, BadgeType } from '@/types/badge.types';
19+
import { UserRankProp } from '@/types/ranking.types';
1820

1921
import { ColorPickerField } from './color-picker-field';
2022
import { StepTitle } from './step-title';
@@ -28,27 +30,19 @@ const BadgeFormItem: FC<PropsWithChildren> = ({ children }) => {
2830
};
2931

3032
// Helper function to generate label based on ranking and type
31-
const generateLabel = (ranking?: string, type?: string): string => {
33+
const generateLabel = (ranking?: UserRankProp, type?: string): string => {
3234
if (type === BadgeType.Score) {
3335
switch (ranking) {
34-
case BadgeRanking.s:
36+
case UserRankProp.s:
3537
return 'Total Stars';
36-
case BadgeRanking.c:
38+
case UserRankProp.c:
3739
return 'Contribution Score';
38-
case BadgeRanking.f:
40+
case UserRankProp.f:
3941
return 'Total Followers';
4042
}
4143
}
4244

43-
switch (ranking) {
44-
case BadgeRanking.c:
45-
return 'Contributor Rank';
46-
case BadgeRanking.f:
47-
return 'Followers Rank';
48-
case BadgeRanking.s:
49-
default:
50-
return 'Stars Rank';
51-
}
45+
return RANK_NAME[ranking ?? UserRankProp.s];
5246
};
5347

5448
export function BadgeForm() {
@@ -96,9 +90,9 @@ export function BadgeForm() {
9690
</SelectTrigger>
9791
</FormControl>
9892
<SelectContent>
99-
<SelectItem value={BadgeRanking.s}>Stars Ranking</SelectItem>
100-
<SelectItem value={BadgeRanking.c}>Contributor Ranking</SelectItem>
101-
<SelectItem value={BadgeRanking.f}>Followers Ranking</SelectItem>
93+
<SelectItem value={UserRankProp.s}>{`${RANK_NAME[UserRankProp.s]}ing`}</SelectItem>
94+
<SelectItem value={UserRankProp.c}>{`${RANK_NAME[UserRankProp.c]}ing`}</SelectItem>
95+
<SelectItem value={UserRankProp.f}>{`${RANK_NAME[UserRankProp.f]}ing`}</SelectItem>
10296
</SelectContent>
10397
</Select>
10498
</BadgeFormItem>

app/badge/gallery/page.tsx

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import { unstable_cacheLife as cacheLife } from 'next/cache';
44

5-
import { BadgeCornerStyle, BadgeContext, BadgeMeta, BadgeType, BadgeRanking } from '@/types/badge.types';
5+
import { RANK_NAME } from '@/badge/badge.consts';
6+
import { BadgeCornerStyle, BadgeContext, BadgeMeta, BadgeType } from '@/types/badge.types';
7+
import { UserRankProp } from '@/types/ranking.types';
68

79
import BadgeExample from './components/badge-example';
810
import { BadgeContainer, BadgeDescription, BadgeExamplesWrapper, BadgeTitle } from './components/badge-helpers';
@@ -22,9 +24,9 @@ export default async function BadgeGallery() {
2224
</BadgeDescription>
2325

2426
<BadgeExamplesWrapper>
25-
<BadgeExample label="Stars Rank" />
26-
<BadgeExample label="Contributor Rank" ranking={BadgeRanking.c} />
27-
<BadgeExample label="Followers Rank" ranking={BadgeRanking.f} />
27+
<BadgeExample label={RANK_NAME.s} />
28+
<BadgeExample label={RANK_NAME.c} ranking={UserRankProp.c} />
29+
<BadgeExample label={RANK_NAME.f} ranking={UserRankProp.f} />
2830
</BadgeExamplesWrapper>
2931
</BadgeContainer>
3032

@@ -39,13 +41,13 @@ export default async function BadgeGallery() {
3941
<BadgeExample label="Total Stars" type={BadgeType.Score} valueBgColor="#1e3a8a" />
4042
<BadgeExample
4143
label="Contribution Score"
42-
ranking={BadgeRanking.c}
44+
ranking={UserRankProp.c}
4345
type={BadgeType.Score}
4446
valueBgColor="#1e3a8a"
4547
/>
4648
<BadgeExample
4749
label="Total Followers"
48-
ranking={BadgeRanking.f}
50+
ranking={UserRankProp.f}
4951
type={BadgeType.Score}
5052
valueBgColor="#1e3a8a"
5153
/>
@@ -61,14 +63,9 @@ export default async function BadgeGallery() {
6163
tier name on your profile page.
6264
</BadgeDescription>
6365
<BadgeExamplesWrapper>
64-
<BadgeExample label="Stars Rank" type={BadgeType.Tier} valueBgColor="#7c3aed" />
65-
<BadgeExample
66-
label="Contributor Rank"
67-
ranking={BadgeRanking.c}
68-
type={BadgeType.Tier}
69-
valueBgColor="#7c3aed"
70-
/>
71-
<BadgeExample label="Followers Rank" ranking={BadgeRanking.f} type={BadgeType.Tier} valueBgColor="#7c3aed" />
66+
<BadgeExample label={RANK_NAME.s} type={BadgeType.Tier} valueBgColor="#7c3aed" />
67+
<BadgeExample label={RANK_NAME.c} ranking={UserRankProp.c} type={BadgeType.Tier} valueBgColor="#7c3aed" />
68+
<BadgeExample label={RANK_NAME.f} ranking={UserRankProp.f} type={BadgeType.Tier} valueBgColor="#7c3aed" />
7269
</BadgeExamplesWrapper>
7370
</BadgeContainer>
7471

@@ -80,16 +77,16 @@ export default async function BadgeGallery() {
8077
having 5+ followers.
8178
</BadgeDescription>
8279
<BadgeExamplesWrapper>
83-
<BadgeExample label="Stars Rank" type={BadgeType.Percentile} valueBgColor="#7f5539" />
80+
<BadgeExample label={RANK_NAME.s} type={BadgeType.Percentile} valueBgColor="#7f5539" />
8481
<BadgeExample
85-
label="Contributor Rank"
86-
ranking={BadgeRanking.c}
82+
label={RANK_NAME.c}
83+
ranking={UserRankProp.c}
8784
type={BadgeType.Percentile}
8885
valueBgColor="#7f5539"
8986
/>
9087
<BadgeExample
91-
label="Followers Rank"
92-
ranking={BadgeRanking.f}
88+
label={RANK_NAME.f}
89+
ranking={UserRankProp.f}
9390
type={BadgeType.Percentile}
9491
valueBgColor="#7f5539"
9592
/>
@@ -103,18 +100,18 @@ export default async function BadgeGallery() {
103100
detect your country from your profile location, ranking you only against developers from that country.
104101
</BadgeDescription>
105102
<BadgeExamplesWrapper>
106-
<BadgeExample label="USA Stars Rank" context={BadgeContext.Country} />
103+
<BadgeExample label={`USA ${RANK_NAME.s}`} context={BadgeContext.Country} />
107104
<BadgeExample
108-
label="Ukraine Followers Rank"
105+
label={`Ukraine ${RANK_NAME.f}`}
109106
context={BadgeContext.Country}
110-
ranking={BadgeRanking.f}
107+
ranking={UserRankProp.f}
111108
type={BadgeType.Tier}
112109
valueBgColor="#7c3aed"
113110
/>
114111
<BadgeExample
115-
label="India Stars Rank"
112+
label={`India ${RANK_NAME.s}`}
116113
context={BadgeContext.Country}
117-
ranking={BadgeRanking.s}
114+
ranking={UserRankProp.s}
118115
type={BadgeType.Percentile}
119116
valueBgColor="#7f5539"
120117
/>
@@ -128,22 +125,22 @@ export default async function BadgeGallery() {
128125
rank change, monthly score change, or how much more you need to reach the next tier or top percentile.
129126
</BadgeDescription>
130127
<BadgeExamplesWrapper>
131-
<BadgeExample label="Stars Rank" meta={BadgeMeta.MonthlyChange} />
128+
<BadgeExample label={RANK_NAME.s} meta={BadgeMeta.MonthlyChange} />
132129
<BadgeExample
133130
label="Total Followers"
134-
ranking={BadgeRanking.f}
131+
ranking={UserRankProp.f}
135132
meta={BadgeMeta.Percentile}
136133
valueBgColor="#1e3a8a"
137134
/>
138-
<BadgeExample label="Stars Rank" ranking={BadgeRanking.s} meta={BadgeMeta.GoalTop10} />
135+
<BadgeExample label={RANK_NAME.s} ranking={UserRankProp.s} meta={BadgeMeta.GoalTop10} />
139136
</BadgeExamplesWrapper>
140137
</BadgeContainer>
141138

142139
<BadgeContainer>
143140
<BadgeTitle>Badge Variants</BadgeTitle>
144141
<BadgeExamplesWrapper>
145-
<BadgeExample label="Stars Rank" />
146-
<BadgeExample label="Stars Rank" cornerStyle={BadgeCornerStyle.Squared} />
142+
<BadgeExample label={RANK_NAME.s} />
143+
<BadgeExample label={RANK_NAME.s} cornerStyle={BadgeCornerStyle.Squared} />
147144
</BadgeExamplesWrapper>
148145
</BadgeContainer>
149146
</div>

app/components/badge-section.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { RANK_NAME } from '@/badge/badge.consts';
12
import { Link } from '@/components/link/link';
2-
import { BadgeMeta, BadgeRanking, BadgeType } from '@/types/badge.types';
3+
import { BadgeMeta, BadgeType } from '@/types/badge.types';
4+
import { UserRankProp } from '@/types/ranking.types';
35

46
import BadgeExample from '../badge/gallery/components/badge-example';
57

@@ -12,23 +14,18 @@ export const BadgeSection = () => {
1214
millions of developers.
1315
</div>
1416
<div className="flex gap-3">
15-
<BadgeExample label="Stars Rank" />
17+
<BadgeExample label={RANK_NAME.s} />
1618
<BadgeExample
1719
label="Contribution Score"
18-
ranking={BadgeRanking.c}
20+
ranking={UserRankProp.c}
1921
type={BadgeType.Score}
2022
valueBgColor="#1e3a8a"
2123
/>
22-
<BadgeExample
23-
label="Contributor Rank"
24-
ranking={BadgeRanking.c}
25-
type={BadgeType.Percentile}
26-
valueBgColor="#7f5539"
27-
/>
28-
<BadgeExample label="Stars Rank" meta={BadgeMeta.MonthlyChange} />
24+
<BadgeExample label={RANK_NAME.c} ranking={UserRankProp.c} type={BadgeType.Percentile} valueBgColor="#7f5539" />
25+
<BadgeExample label={RANK_NAME.s} meta={BadgeMeta.MonthlyChange} />
2926
<BadgeExample
3027
label="Total Followers"
31-
ranking={BadgeRanking.f}
28+
ranking={UserRankProp.f}
3229
meta={BadgeMeta.Percentile}
3330
valueBgColor="#1e3a8a"
3431
/>

app/profile/[login]/components/tier-value.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { TagProvisional } from '@/components/tag-provisional/tag-provisional';
66
import { TiersExplanation } from '@/components/tiers-explanation/tiers-explanation';
77
import { cn } from '@/lib/utils';
88
import { Tier } from '@/types/generated/graphql';
9-
import { UserRankProps } from '@/types/ranking.types';
9+
import { UserRankProp } from '@/types/ranking.types';
1010
import { hasTierData } from '@/utils/calculate-tiers/calculate-tiers';
1111
import { ProfileTierType } from '@/utils/calculate-tiers/calculate-tiers.types';
1212

@@ -16,7 +16,7 @@ type TierValueProps = {
1616
className?: string;
1717
tiers?: Tier[];
1818
rankedCount?: number;
19-
rankType: UserRankProps;
19+
rankType: UserRankProp;
2020
};
2121

2222
const getTierName = (tierData?: ProfileTierType): string => {

app/profile/[login]/country/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { notFound } from 'next/navigation';
66
import { Link } from '@/components/link/link';
77
import { fetchProfileData } from '@/graphql/helpers/fetch-profile-data';
88
import { fetchRankTiers } from '@/graphql/helpers/fetch-rank-tiers';
9+
import { UserRankProp } from '@/types/ranking.types';
910
import { calculateTiers } from '@/utils/calculate-tiers/calculate-tiers';
1011

1112
import { RankCard } from '../../../../components/rank-card/rank-card';
@@ -65,7 +66,7 @@ export default async function ProfileRanks({ params }: { params: Promise<{ login
6566
<RankCard
6667
tiers={rankTiers?.sTiers}
6768
tierData={sTier}
68-
rankType="s"
69+
rankType={UserRankProp.s}
6970
rank={s}
7071
rankM={sM}
7172
rankProvisional={sProvisional}
@@ -76,7 +77,7 @@ export default async function ProfileRanks({ params }: { params: Promise<{ login
7677
<RankCard
7778
tiers={rankTiers?.cTiers}
7879
tierData={cTier}
79-
rankType="c"
80+
rankType={UserRankProp.c}
8081
rank={c}
8182
rankM={cM}
8283
rankProvisional={cProvisional}
@@ -86,7 +87,7 @@ export default async function ProfileRanks({ params }: { params: Promise<{ login
8687
<RankCard
8788
tiers={rankTiers?.fTiers}
8889
tierData={fTier}
89-
rankType="f"
90+
rankType={UserRankProp.f}
9091
rank={f}
9192
rankM={fM}
9293
rankProvisional={fProvisional}

app/profile/[login]/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { notFound } from 'next/navigation';
55

66
import { fetchProfileData } from '@/graphql/helpers/fetch-profile-data';
77
import { fetchRankTiers } from '@/graphql/helpers/fetch-rank-tiers';
8+
import { UserRankProp } from '@/types/ranking.types';
89
import { calculateTiers } from '@/utils/calculate-tiers/calculate-tiers';
910

1011
import { LayoutLeftColumn } from './components/layout-left-column';
@@ -59,7 +60,7 @@ export default async function ProfileRanks({ params }: { params: Promise<{ login
5960
<RankCard
6061
tiers={rankTiers?.sTiers}
6162
tierData={sTier}
62-
rankType="s"
63+
rankType={UserRankProp.s}
6364
rank={s}
6465
rankM={sM}
6566
rankProvisional={sProvisional}
@@ -69,7 +70,7 @@ export default async function ProfileRanks({ params }: { params: Promise<{ login
6970
<RankCard
7071
tiers={rankTiers?.cTiers}
7172
tierData={cTier}
72-
rankType="c"
73+
rankType={UserRankProp.c}
7374
rank={c}
7475
rankM={cM}
7576
rankProvisional={cProvisional}
@@ -79,7 +80,7 @@ export default async function ProfileRanks({ params }: { params: Promise<{ login
7980
<RankCard
8081
tiers={rankTiers?.fTiers}
8182
tierData={fTier}
82-
rankType="f"
83+
rankType={UserRankProp.f}
8384
rank={f}
8485
rankM={fM}
8586
rankProvisional={fProvisional}

app/profile/[login]/repositories/components/contribution-repository-card.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { FC } from 'react';
22

33
import { Badge } from '@/components/ui/badge';
44
import { Repository } from '@/types/generated/graphql';
5+
import { pluralize } from '@/utils/pluralize';
56

67
import { RepositoryCard } from './repository-card';
78

@@ -33,7 +34,7 @@ export const ContributionRepositoryCard: FC<RepositoryCardProps> = ({
3334
const badgeLabel =
3435
(prsCount ?? 0) > PR_FETCH_LIMIT && (mergedPrsCount ?? 0) >= PR_FETCH_LIMIT / 2
3536
? `~${prsCount} PRs`
36-
: `${mergedPrsCount} PR${(mergedPrsCount ?? 0) > 1 ? 's' : ''}`;
37+
: `${mergedPrsCount} ${pluralize('PR', mergedPrsCount ?? 0)}`;
3738

3839
return (
3940
<RepositoryCard

app/profile/[login]/sitemap.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import { startOfMonth } from 'date-fns';
2+
import { cacheLife } from 'next/dist/server/use-cache/cache-life';
23

4+
import { RANK_NAME } from '@/badge/badge.consts';
35
import { graphqlDirect } from '@/lib/graphql/graphql-direct';
46
import { ProfilesForSitemapDocument } from '@/types/generated/graphql';
5-
import { RankingType } from '@/types/ranking.types';
7+
import { UserRankProp } from '@/types/ranking.types';
68

79
export default async function sitemap() {
10+
cacheLife('hours');
11+
812
const { profilesForSitemap } = (await graphqlDirect(ProfilesForSitemapDocument)) ?? {};
913
const startOfMonthDate = startOfMonth(new Date());
10-
const rankingTypes: RankingType[] = Object.values(RankingType) as RankingType[];
14+
const rankingTypes = Object.values(UserRankProp);
1115

1216
return profilesForSitemap.map((profile) => ({
1317
url: `${process.env.NEXT_PUBLIC_URI}/profile/${profile.login}`,
1418
lastModified: startOfMonthDate.toISOString(),
1519
changeFrequency: 'monthly',
1620
images: rankingTypes.map(
1721
(rankingType) =>
18-
`${process.env.NEXT_PUBLIC_URI}/api/badge/${profile.login}?rankingType=${rankingType}&amp;template=medium`,
22+
`${process.env.NEXT_PUBLIC_URI}/api/badge/v2/${profile.login}?ranking=${rankingType}&context=global&type=position&meta=none&label=${RANK_NAME[rankingType]}`,
1923
),
2024
priority: 0.95,
2125
}));

0 commit comments

Comments
 (0)