this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix logic

Co-authored-by: Copilot <copilot@github.com>

nove-b 48b40af3 eeeff42d

+26 -4
+26 -4
src/tangledGraph.ts
··· 307 307 308 308 function buildMonthLabels(days: HeatmapDay[]): Array<{ label: string; weekIndex: number }> { 309 309 const seen = new Set<string>(); 310 - const labels: Array<{ label: string; weekIndex: number }> = []; 310 + const rawLabels: Array<{ monthName: string; year: number; weekIndex: number }> = []; 311 311 312 312 for (const day of days) { 313 313 if (!day.inRange) { ··· 320 320 } 321 321 322 322 seen.add(key); 323 - labels.push({ 324 - label: MONTH_LABELS[day.date.getUTCMonth()], 323 + rawLabels.push({ 324 + monthName: MONTH_LABELS[day.date.getUTCMonth()], 325 + year: day.date.getUTCFullYear(), 325 326 weekIndex: day.weekIndex, 326 327 }); 327 328 } 328 329 329 - return labels; 330 + // どの月名が重複するか先に調べる 331 + const monthNameCount = new Map<string, number>(); 332 + for (const { monthName } of rawLabels) { 333 + monthNameCount.set(monthName, (monthNameCount.get(monthName) ?? 0) + 1); 334 + } 335 + 336 + // 重複する月名は最初の出現のみ表示(右端の同名月はスキップ) 337 + const seenMonthNames = new Set<string>(); 338 + return rawLabels.flatMap(({ monthName, year, weekIndex }) => { 339 + const isDuplicate = (monthNameCount.get(monthName) ?? 0) > 1; 340 + if (isDuplicate) { 341 + if (seenMonthNames.has(monthName)) { 342 + return []; 343 + } 344 + seenMonthNames.add(monthName); 345 + // 最初の出現は年なしで表示 346 + return [{ label: monthName, weekIndex }]; 347 + } 348 + const isJanuary = monthName === 'Jan'; 349 + const label = isJanuary ? `${monthName} '${String(year).slice(2)}` : monthName; 350 + return [{ label, weekIndex }]; 351 + }); 330 352 } 331 353 332 354 function activityLevel(count: number): 0 | 1 | 2 | 3 | 4 {