Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/api/streak/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
calculateStreak,
calculateMonthlyStats,
aggregateCalendars,
convertLocalToUtc,

Check warning on line 16 in app/api/streak/route.ts

View workflow job for this annotation

GitHub Actions / Format Β· Lint Β· Typecheck Β· Test

'convertLocalToUtc' is defined but never used
chunkDaysIntoWeeks,
normalizeCalendarToTimezone,
isLeapYear,

Check warning on line 19 in app/api/streak/route.ts

View workflow job for this annotation

GitHub Actions / Format Β· Lint Β· Typecheck Β· Test

'isLeapYear' is defined but never used
daysInYear,
} from '@/lib/calculate';
import {
Expand Down Expand Up @@ -55,7 +55,7 @@

import { validationCache as _vc, normalizeCacheKey, cachedValidation } from './validation-cache';
// Re-alias so existing usages in this file continue to work.
const validationCache = _vc;

Check warning on line 58 in app/api/streak/route.ts

View workflow job for this annotation

GitHub Actions / Format Β· Lint Β· Typecheck Β· Test

'validationCache' is assigned a value but never used

const SVG_CSP_HEADER =
"default-src 'none'; style-src 'unsafe-inline' https://fonts.googleapis.com; font-src https://fonts.gstatic.com; connect-src https://fonts.gstatic.com;";
Expand Down Expand Up @@ -169,6 +169,7 @@
phi,
border,
minify,
hide_weekend,
} = parseResult.data;
const normalizedView = view as
| 'default'
Expand Down Expand Up @@ -406,6 +407,7 @@
theta,
phi,
compact,
hide_weekend,
};

let calendar;
Expand Down
11 changes: 9 additions & 2 deletions lib/svg/weekday.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ export function generateWeekdaySVG(
params: BadgeParams,
calendar: ContributionCalendar
): string {
const grouped = groupByWeekday(calendar);
let grouped = groupByWeekday(calendar);

if (params.hide_weekend) {
// Keep only Mon-Fri
grouped = grouped.filter((d, i) => i !== 0 && i !== 6);
}

const max = Math.max(...grouped.map((d) => d.total), 1);
const peakIndex = grouped.reduce((best, d, i, arr) => (d.total > arr[best].total ? i : best), 0);

Expand All @@ -59,7 +65,8 @@ export function generateWeekdaySVG(
// Reserve ~40px at the top for the contributions subtitle and ~40px at the
// bottom for the day-of-week labels, leaving the remainder for bar height.
const chartHeight = height - 80;
const startX = (width - (7 * barWidth + 6 * gap)) / 2;
const numBars = grouped.length;
const startX = (width - (numBars * barWidth + (numBars - 1) * gap)) / 2;

// params.accent can be HexColor | HexColor[] β€” normalize to a single color
const accentColor = Array.isArray(params.accent)
Expand Down
1 change: 1 addition & 0 deletions lib/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ const baseStreakParamsSchema = z.object({
.catch('rise')
.default('rise'),
badges: z.string().optional().transform(toBooleanFlag).default(false),
hide_weekend: z.string().optional().transform(toBooleanFlag).default(false),

// Output format: 'svg' (default), 'json', or 'png' for image export.
// Invalid values silently fall back to 'svg'.
Expand Down
3 changes: 3 additions & 0 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ export interface BadgeParams {
/** When true, renders a compact single-row card (~100px tall) with only username, avatar, and streak count. Skips the full isometric grid. */
compact?: boolean;

/** When true, hides Saturday and Sunday from the weekday chart */
hide_weekend?: boolean;

/** @internal Temporary property to track custom gradient ID during SVG generation. */
__customGradientId?: string;
}
Expand Down
Loading