+
+
{list.map((item, i) => (
{item}
diff --git a/src/components/sections/__tests__/certificate-list.test.tsx b/src/components/sections/__tests__/certificate-list.test.tsx
new file mode 100644
index 0000000..6e04498
--- /dev/null
+++ b/src/components/sections/__tests__/certificate-list.test.tsx
@@ -0,0 +1,27 @@
+import { render, screen } from '@testing-library/react';
+import type { ReactNode } from 'react';
+import { CertificateList } from '../certificate-list';
+
+jest.mock('@/components/cyber/primitives', () => ({
+ Reveal: ({ children }: { children: ReactNode }) => {children},
+}));
+
+test('shows four certificates and preserves the rest behind a native disclosure', () => {
+ const certificates = Array.from({ length: 9 }, (_, i) => ({ name: `Certificate ${i + 1}`, issuer: 'Issuer', year: 2026, url: `https://example.com/${i}` }));
+ render();
+ expect(screen.getByText('Certificate 1').closest('ul')?.children).toHaveLength(4);
+ expect(screen.getByText('Show all 9 certificates (+5)')).toBeVisible();
+ expect(screen.getByText('Certificate 9')).not.toBeVisible();
+ const details = screen.getByText('Certificate 9').closest('details')!;
+ details.open = true;
+ expect(screen.getByText('Certificate 9')).toBeVisible();
+ expect(screen.getByRole('link', { name: /Certificate 9/ })).toHaveAttribute('href', 'https://example.com/8');
+ details.open = false;
+ expect(screen.getByText('Certificate 1').closest('ul')?.children).toHaveLength(4);
+});
+
+test('does not add an unnecessary disclosure for a short list', () => {
+ render();
+ expect(screen.getAllByRole('listitem')).toHaveLength(1);
+ expect(screen.queryByText(/Show all/)).not.toBeInTheDocument();
+});
diff --git a/src/components/sections/about.tsx b/src/components/sections/about.tsx
index 27dbf56..9242bb9 100644
--- a/src/components/sections/about.tsx
+++ b/src/components/sections/about.tsx
@@ -1,3 +1,4 @@
+import { CertificateList, type Certificate } from './certificate-list';
import { Github, Linkedin, ArrowUpRight } from 'lucide-react';
import { Reveal, ScrambleText, TiltCard } from '@/components/cyber/primitives';
@@ -16,12 +17,7 @@ interface Education {
duration: string;
}
-interface Certificate {
- name: string;
- issuer: string;
- year: number;
- url?: string | null;
-}
+
export function AboutSection({
personalData,
@@ -164,35 +160,7 @@ export function AboutSection({
{'// clearances'}
資格
-
- {certificates.map((cert, i) => (
-
- {(() => {
- const body = (
- <>
-
-
{cert.name}
-
- {cert.issuer}
- {cert.url && ' · verify ↗'}
-
-
- {cert.year}
- >
- );
- const cls =
- 'clip-notch-sm group relative flex items-center justify-between gap-4 bg-card px-4 py-3 transition-colors hover:bg-signal hover:text-ink';
- return cert.url ? (
-
- {body}
-
- ) : (
- {body}
- );
- })()}
-
- ))}
-
+
)}
diff --git a/src/components/sections/certificate-list.tsx b/src/components/sections/certificate-list.tsx
new file mode 100644
index 0000000..dd5494f
--- /dev/null
+++ b/src/components/sections/certificate-list.tsx
@@ -0,0 +1,42 @@
+import { Reveal } from '@/components/cyber/primitives';
+
+export interface Certificate {
+ name: string;
+ issuer: string;
+ year: number;
+ url?: string | null;
+}
+
+function CertificateCards({ certificates }: { certificates: Certificate[] }) {
+ return (
+
+ );
+}
+
+export function CertificateList({ certificates }: { certificates: Certificate[] }) {
+ const limit = 4;
+ return <>
+
+ {certificates.length > limit &&
+
+ Show all {certificates.length} certificates (+{certificates.length - limit})
+ Show fewer certificates
+
+
+ }
+ >;
+}
diff --git a/src/components/sections/skills.tsx b/src/components/sections/skills.tsx
index 28f44f5..e124417 100644
--- a/src/components/sections/skills.tsx
+++ b/src/components/sections/skills.tsx
@@ -87,8 +87,8 @@ export function SkillsSection({ skills }: { skills: Skills | null }) {
{all.length > 0 && (
-
-
+
+
)}
diff --git a/src/lib/__tests__/not-found-quotes.test.ts b/src/lib/__tests__/not-found-quotes.test.ts
index 831702b..8381e84 100644
--- a/src/lib/__tests__/not-found-quotes.test.ts
+++ b/src/lib/__tests__/not-found-quotes.test.ts
@@ -1,16 +1,27 @@
-import { NOT_FOUND_QUOTES, NOT_FOUND_QUOTE_KEY, takeNotFoundQuote } from '../not-found-quotes';
+import { NOT_FOUND_QUOTES, NOT_FOUND_QUOTE_KEY, getQuoteClock, quoteIndexAt } from '../not-found-quotes';
-describe('lost-route quote rotation', () => {
+describe('lost-route quote clock', () => {
+ const now = 1_790_000_000_000;
beforeEach(() => sessionStorage.clear());
- it('cycles through ten distinct quotes and wraps on the next visit', () => {
- expect(new Set(NOT_FOUND_QUOTES).size).toBe(10);
- expect(Array.from({ length: 11 }, () => takeNotFoundQuote(sessionStorage))).toEqual([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]);
+ it('has twenty distinct quotes and changes at ten-second boundaries', () => {
+ expect(new Set(NOT_FOUND_QUOTES).size).toBe(20);
+ expect(quoteIndexAt(now, now + 9999)).toBe(0);
+ expect(quoteIndexAt(now, now + 10000)).toBe(1);
+ expect(quoteIndexAt(now, now + 199999)).toBe(19);
+ expect(quoteIndexAt(now, now + 200000)).toBe(0);
});
- it.each(['NaN', '-1', '10', '1.5', 'Infinity'])('recovers from an invalid saved index: %s', (value) => {
+ it('preserves the clock on refresh and catches up after an inactive tab', () => {
+ expect(getQuoteClock(sessionStorage, now)).toBe(now);
+ const anchor = getQuoteClock(sessionStorage, now + 17000);
+ expect(anchor).toBe(now);
+ expect(quoteIndexAt(anchor, now + 20000)).toBe(2);
+ expect(quoteIndexAt(anchor, now + 65000)).toBe(6);
+ });
+
+ it.each(['NaN', '-1', '0', '1.5', 'Infinity', String(now + 1)])('recovers from an invalid saved clock: %s', (value) => {
sessionStorage.setItem(NOT_FOUND_QUOTE_KEY, value);
- expect(takeNotFoundQuote(sessionStorage)).toBe(0);
- expect(takeNotFoundQuote(sessionStorage)).toBe(1);
+ expect(getQuoteClock(sessionStorage, now)).toBe(now);
});
});
diff --git a/src/lib/not-found-quotes.ts b/src/lib/not-found-quotes.ts
index 34a8381..f53eeea 100644
--- a/src/lib/not-found-quotes.ts
+++ b/src/lib/not-found-quotes.ts
@@ -10,15 +10,30 @@ export const NOT_FOUND_QUOTES = [
'Access denied is a boundary. Not found is a question.',
'The hardest truth: waiting will not create the missing page.',
'Lost is a location, not an identity.',
+ 'A perfect illusion still breaks when you ask the right question.',
+ 'The truth does not become kinder because you look away.',
+ 'Every mask hides a face. Every silence hides a story.',
+ 'You can patch a system. You must choose to change yourself.',
+ 'Some battles end only when you stop fighting your own reflection.',
+ 'No map can replace the courage to take the next step.',
+ 'The empty page cannot answer for the life you postponed.',
+ 'A crow leaves no footprints in the sky. Keep looking anyway.',
+ 'Knowing the vulnerability is not the same as fixing it.',
+ 'Even in the dark, you can decide which way to turn.',
] as const;
-export const NOT_FOUND_QUOTE_KEY = 'nd-404-next-quote';
+export const NOT_FOUND_QUOTE_KEY = 'nd-404-quote-clock';
+export const QUOTE_INTERVAL_MS = 10_000;
-/** Persist the next index, so reloads and return visits cycle without repeats. */
-export function takeNotFoundQuote(storage: Pick
): number {
+/** A persistent clock keeps the same ten-second cadence across refreshes. */
+export function getQuoteClock(storage: Pick, now: number): number {
const value = storage.getItem(NOT_FOUND_QUOTE_KEY);
- const parsed = value === null ? 0 : Number(value);
- const index = Number.isInteger(parsed) && parsed >= 0 && parsed < NOT_FOUND_QUOTES.length ? parsed : 0;
- storage.setItem(NOT_FOUND_QUOTE_KEY, String((index + 1) % NOT_FOUND_QUOTES.length));
- return index;
+ const saved = value === null ? NaN : Number(value);
+ if (Number.isSafeInteger(saved) && saved > 0 && saved <= now) return saved;
+ storage.setItem(NOT_FOUND_QUOTE_KEY, String(now));
+ return now;
+}
+
+export function quoteIndexAt(anchor: number, now: number): number {
+ return Math.floor(Math.max(0, now - anchor) / QUOTE_INTERVAL_MS) % NOT_FOUND_QUOTES.length;
}