-
Notifications
You must be signed in to change notification settings - Fork 287
Expand file tree
/
Copy pathindex.html
More file actions
764 lines (672 loc) · 24.4 KB
/
index.html
File metadata and controls
764 lines (672 loc) · 24.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Claude Code Examples Catalog</title>
<meta name="description" content="Browse 50+ ready-to-use templates for Claude Code: agents, commands, hooks, skills, and more.">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css">
<style>
:root {
--bg-primary: #0d1117;
--bg-secondary: #161b22;
--bg-tertiary: #21262d;
--border-default: #30363d;
--border-muted: #21262d;
--text-primary: #e6edf3;
--text-secondary: #8b949e;
--text-muted: #6e7681;
--accent-green: #238636;
--accent-green-hover: #2ea043;
--accent-blue: #58a6ff;
--accent-purple: #a371f7;
--accent-orange: #d29922;
--accent-red: #f85149;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
background-color: var(--bg-primary);
color: var(--text-primary);
line-height: 1.5;
min-height: 100vh;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 2rem 1rem;
}
header {
text-align: center;
margin-bottom: 2rem;
padding-bottom: 2rem;
border-bottom: 1px solid var(--border-default);
}
h1 {
font-size: 2rem;
font-weight: 600;
margin-bottom: 0.5rem;
}
.subtitle {
color: var(--text-secondary);
font-size: 1.1rem;
}
.search-bar {
display: flex;
gap: 1rem;
margin: 2rem auto;
max-width: 600px;
}
.search-input {
flex: 1;
padding: 0.75rem 1rem;
background-color: var(--bg-secondary);
border: 1px solid var(--border-default);
border-radius: 6px;
color: var(--text-primary);
font-size: 1rem;
}
.search-input:focus {
outline: none;
border-color: var(--accent-blue);
box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.3);
}
.search-input::placeholder {
color: var(--text-muted);
}
.stats {
display: flex;
gap: 2rem;
justify-content: center;
margin-bottom: 2rem;
flex-wrap: wrap;
}
.stat {
text-align: center;
}
.stat-number {
font-size: 1.5rem;
font-weight: 600;
color: var(--accent-blue);
}
.stat-label {
color: var(--text-secondary);
font-size: 0.875rem;
}
.category {
margin-bottom: 1.5rem;
background-color: var(--bg-secondary);
border: 1px solid var(--border-default);
border-radius: 8px;
overflow: hidden;
}
.category-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 1rem 1.25rem;
cursor: pointer;
user-select: none;
transition: background-color 0.15s;
}
.category-header:hover {
background-color: var(--bg-tertiary);
}
.category-title {
display: flex;
align-items: center;
gap: 0.75rem;
font-size: 1.1rem;
font-weight: 600;
}
.category-icon {
font-size: 1.25rem;
}
.category-count {
background-color: var(--bg-tertiary);
color: var(--text-secondary);
padding: 0.125rem 0.5rem;
border-radius: 10px;
font-size: 0.75rem;
font-weight: 500;
}
.category-toggle {
color: var(--text-secondary);
transition: transform 0.2s;
}
.category.expanded .category-toggle {
transform: rotate(180deg);
}
.category-content {
display: none;
border-top: 1px solid var(--border-default);
}
.category.expanded .category-content {
display: block;
}
.category-description {
padding: 0.75rem 1.25rem;
color: var(--text-secondary);
font-size: 0.875rem;
background-color: var(--bg-tertiary);
}
.file-list {
list-style: none;
}
.file-item {
border-bottom: 1px solid var(--border-muted);
}
.file-item:last-child {
border-bottom: none;
}
.file-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.75rem 1.25rem;
gap: 1rem;
}
.file-info {
flex: 1;
min-width: 0;
}
.file-name {
font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
font-size: 0.875rem;
color: var(--accent-blue);
text-decoration: none;
}
.file-name:hover {
text-decoration: underline;
}
.file-description {
font-size: 0.8125rem;
color: var(--text-secondary);
margin-top: 0.25rem;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.file-actions {
display: flex;
gap: 0.5rem;
flex-shrink: 0;
}
.btn {
padding: 0.375rem 0.75rem;
border-radius: 6px;
font-size: 0.75rem;
font-weight: 500;
cursor: pointer;
transition: all 0.15s;
border: 1px solid var(--border-default);
background-color: var(--bg-tertiary);
color: var(--text-primary);
}
.btn:hover {
background-color: var(--border-default);
}
.btn-view {
background-color: transparent;
}
.btn-view.active {
background-color: var(--accent-blue);
border-color: var(--accent-blue);
color: white;
}
.btn-copy {
background-color: var(--accent-green);
border-color: var(--accent-green);
color: white;
}
.btn-copy:hover {
background-color: var(--accent-green-hover);
}
.btn-copy.copied {
background-color: var(--accent-purple);
border-color: var(--accent-purple);
}
.btn-download {
background-color: transparent;
color: var(--text-secondary);
}
.file-content {
display: none;
padding: 0;
background-color: var(--bg-primary);
border-top: 1px solid var(--border-muted);
}
.file-item.viewing .file-content {
display: block;
}
.file-content pre {
margin: 0;
padding: 1rem 1.25rem;
overflow-x: auto;
font-size: 0.8125rem;
line-height: 1.6;
}
.file-content code {
font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}
.toast {
position: fixed;
bottom: 2rem;
left: 50%;
transform: translateX(-50%) translateY(100px);
background-color: var(--accent-green);
color: white;
padding: 0.75rem 1.5rem;
border-radius: 8px;
font-weight: 500;
opacity: 0;
transition: all 0.3s;
z-index: 1000;
}
.toast.show {
transform: translateX(-50%) translateY(0);
opacity: 1;
}
.no-results {
text-align: center;
padding: 3rem;
color: var(--text-secondary);
}
.no-results-icon {
font-size: 3rem;
margin-bottom: 1rem;
}
footer {
text-align: center;
margin-top: 3rem;
padding-top: 2rem;
border-top: 1px solid var(--border-default);
color: var(--text-secondary);
font-size: 0.875rem;
}
footer a {
color: var(--accent-blue);
text-decoration: none;
}
footer a:hover {
text-decoration: underline;
}
@media (max-width: 640px) {
.container {
padding: 1rem 0.75rem;
}
h1 {
font-size: 1.5rem;
}
.stats {
gap: 1rem;
}
.file-header {
flex-wrap: wrap;
}
.file-actions {
width: 100%;
justify-content: flex-end;
margin-top: 0.5rem;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>Claude Code Examples</h1>
<p class="subtitle">Ready-to-use templates for agents, commands, hooks, and more</p>
</header>
<div class="search-bar">
<input type="text" class="search-input" id="searchInput" placeholder="Search examples..." autocomplete="off">
</div>
<div class="stats" id="stats"></div>
<main id="catalog"></main>
<div id="noResults" class="no-results" style="display: none;">
<div class="no-results-icon">🔍</div>
<p>No examples found matching your search.</p>
</div>
<footer>
<p>
Part of the <a href="https://github.com/anthropics/claude-code-guide">Claude Code Ultimate Guide</a>
• <a href="../guide/ultimate-guide.md">Read the Guide</a>
• <a href="./README.md">View on GitHub</a>
</p>
</footer>
</div>
<div class="toast" id="toast">Copied to clipboard!</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/powershell.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/yaml.min.js"></script>
<script>
// Examples data structure
const EXAMPLES = {
agents: {
icon: "🤖",
description: "Custom AI personas for specialized tasks. Place in .claude/agents/ or ~/.claude/agents/",
files: [
{ name: "code-reviewer.md", path: "agents/code-reviewer.md", description: "Thorough code review with best practices" },
{ name: "test-writer.md", path: "agents/test-writer.md", description: "TDD/BDD test generation specialist" },
{ name: "security-auditor.md", path: "agents/security-auditor.md", description: "Security vulnerability detection (OWASP)" },
{ name: "refactoring-specialist.md", path: "agents/refactoring-specialist.md", description: "Clean code refactoring expert" },
{ name: "output-evaluator.md", path: "agents/output-evaluator.md", description: "LLM-as-a-Judge quality gate" }
]
},
skills: {
icon: "📚",
description: "Reusable knowledge modules. Place in .claude/skills/ or ~/.claude/skills/",
files: [
{ name: "tdd-workflow.md", path: "skills/tdd-workflow.md", description: "Test-Driven Development process" },
{ name: "security-checklist.md", path: "skills/security-checklist.md", description: "OWASP Top 10 security checks" }
]
},
commands: {
icon: "⚡",
description: "Custom slash commands. Place in .claude/commands/ or ~/.claude/commands/",
files: [
{ name: "commit.md", path: "commands/commit.md", description: "/commit - Conventional commit messages" },
{ name: "pr.md", path: "commands/pr.md", description: "/pr - Create well-structured PRs" },
{ name: "review-pr.md", path: "commands/review-pr.md", description: "/review-pr - PR review workflow" },
{ name: "release-notes.md", path: "commands/release-notes.md", description: "/release-notes - Generate in 3 formats" },
{ name: "sonarqube.md", path: "commands/sonarqube.md", description: "/sonarqube - Analyze SonarCloud issues" },
{ name: "generate-tests.md", path: "commands/generate-tests.md", description: "/generate-tests - Test generation" },
{ name: "git-worktree.md", path: "commands/git-worktree.md", description: "/git-worktree - Isolated worktree setup" },
{ name: "diagnose.md", path: "commands/diagnose.md", description: "/diagnose - Interactive troubleshooting" },
{ name: "validate-changes.md", path: "commands/validate-changes.md", description: "/validate-changes - Pre-commit validation" }
]
},
"hooks/bash": {
icon: "🔒",
description: "Event-driven automation scripts (Bash). Place in .claude/hooks/ or ~/.claude/hooks/",
files: [
{ name: "dangerous-actions-blocker.sh", path: "hooks/bash/dangerous-actions-blocker.sh", description: "Block dangerous commands/edits" },
{ name: "security-check.sh", path: "hooks/bash/security-check.sh", description: "Block secrets in commands" },
{ name: "prompt-injection-detector.sh", path: "hooks/bash/prompt-injection-detector.sh", description: "Detect injection attempts" },
{ name: "unicode-injection-scanner.sh", path: "hooks/bash/unicode-injection-scanner.sh", description: "Detect zero-width, RTL, ANSI escape" },
{ name: "repo-integrity-scanner.sh", path: "hooks/bash/repo-integrity-scanner.sh", description: "Scan README/package.json for injection" },
{ name: "mcp-config-integrity.sh", path: "hooks/bash/mcp-config-integrity.sh", description: "Verify MCP config hash (CVE)" },
{ name: "output-secrets-scanner.sh", path: "hooks/bash/output-secrets-scanner.sh", description: "Detect secrets in output" },
{ name: "auto-format.sh", path: "hooks/bash/auto-format.sh", description: "Auto-format after edits" },
{ name: "notification.sh", path: "hooks/bash/notification.sh", description: "macOS sound alerts" },
{ name: "output-validator.sh", path: "hooks/bash/output-validator.sh", description: "Heuristic output validation" },
{ name: "session-logger.sh", path: "hooks/bash/session-logger.sh", description: "Log operations for monitoring" },
{ name: "pre-commit-evaluator.sh", path: "hooks/bash/pre-commit-evaluator.sh", description: "LLM-as-a-Judge pre-commit" },
{ name: "privacy-warning.sh", path: "hooks/bash/privacy-warning.sh", description: "Warn on privacy-sensitive ops" },
{ name: "claudemd-scanner.sh", path: "hooks/bash/claudemd-scanner.sh", description: "Scan CLAUDE.md for issues" }
]
},
"hooks/powershell": {
icon: "🪟",
description: "Event-driven automation scripts (PowerShell/Windows)",
files: [
{ name: "security-check.ps1", path: "hooks/powershell/security-check.ps1", description: "Block secrets in commands" },
{ name: "auto-format.ps1", path: "hooks/powershell/auto-format.ps1", description: "Auto-format after edits" }
]
},
config: {
icon: "⚙️",
description: "Configuration file templates. Place in .claude/ or ~/.claude/",
files: [
{ name: "settings.json", path: "config/settings.json", description: "Hooks and preferences config" },
{ name: "mcp.json", path: "config/mcp.json", description: "MCP servers configuration" },
{ name: ".gitignore-claude", path: "config/.gitignore-claude", description: "Git ignore patterns for Claude files" }
]
},
memory: {
icon: "🧠",
description: "CLAUDE.md memory file templates for persistent context",
files: [
{ name: "CLAUDE.md.project-template", path: "memory/CLAUDE.md.project-template", description: "Team project memory template" },
{ name: "CLAUDE.md.personal-template", path: "memory/CLAUDE.md.personal-template", description: "Personal global memory template" }
]
},
scripts: {
icon: "🛠️",
description: "Utility scripts for setup, diagnostics, and monitoring",
files: [
{ name: "audit-scan.sh", path: "scripts/audit-scan.sh", description: "Fast setup audit scanner" },
{ name: "check-claude.sh", path: "scripts/check-claude.sh", description: "Health check (macOS/Linux)" },
{ name: "check-claude.ps1", path: "scripts/check-claude.ps1", description: "Health check (Windows)" },
{ name: "clean-reinstall-claude.sh", path: "scripts/clean-reinstall-claude.sh", description: "Clean reinstall (macOS/Linux)" },
{ name: "clean-reinstall-claude.ps1", path: "scripts/clean-reinstall-claude.ps1", description: "Clean reinstall (Windows)" },
{ name: "session-stats.sh", path: "scripts/session-stats.sh", description: "Analyze session logs & costs" },
{ name: "session-search.sh", path: "scripts/session-search.sh", description: "Search & resume sessions" }
]
},
"github-actions": {
icon: "🚀",
description: "CI/CD workflows for GitHub Actions automation",
files: [
{ name: "claude-pr-auto-review.yml", path: "github-actions/claude-pr-auto-review.yml", description: "Auto code review on PRs" },
{ name: "claude-security-review.yml", path: "github-actions/claude-security-review.yml", description: "Security-focused PR scan" },
{ name: "claude-issue-triage.yml", path: "github-actions/claude-issue-triage.yml", description: "Auto-triage issues with labels" }
]
},
workflows: {
icon: "📋",
description: "Advanced development workflow guides",
files: [
{ name: "database-branch-setup.md", path: "workflows/database-branch-setup.md", description: "Isolated feature dev with DB branches" }
]
},
modes: {
icon: "🎭",
description: "Behavioral modes for Claude (SuperClaude framework). Place in ~/.claude/",
files: [
{ name: "MODE_Learning.md", path: "modes/MODE_Learning.md", description: "Just-in-time explanations mode" }
]
}
};
// State
let contentCache = {};
let expandedCategories = new Set();
// DOM elements
const catalogEl = document.getElementById('catalog');
const statsEl = document.getElementById('stats');
const searchInput = document.getElementById('searchInput');
const noResultsEl = document.getElementById('noResults');
const toastEl = document.getElementById('toast');
// Utility functions
function getLanguage(filename) {
const ext = filename.split('.').pop().toLowerCase();
const langMap = {
'md': 'markdown',
'json': 'json',
'yml': 'yaml',
'yaml': 'yaml',
'sh': 'bash',
'ps1': 'powershell',
'gitignore': 'plaintext'
};
return langMap[ext] || 'plaintext';
}
function showToast(message) {
toastEl.textContent = message;
toastEl.classList.add('show');
setTimeout(() => toastEl.classList.remove('show'), 2000);
}
async function loadContent(path) {
if (contentCache[path]) {
return contentCache[path];
}
try {
const response = await fetch(path);
if (!response.ok) throw new Error('Failed to load');
const text = await response.text();
contentCache[path] = text;
return text;
} catch (error) {
return `Error loading file: ${error.message}`;
}
}
async function copyToClipboard(path) {
const content = await loadContent(path);
try {
await navigator.clipboard.writeText(content);
showToast('Copied to clipboard!');
return true;
} catch (error) {
showToast('Failed to copy');
return false;
}
}
function downloadFile(path, filename) {
const a = document.createElement('a');
a.href = path;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
async function toggleView(path, contentEl, viewBtn) {
const fileItem = contentEl.closest('.file-item');
const isViewing = fileItem.classList.contains('viewing');
if (isViewing) {
fileItem.classList.remove('viewing');
viewBtn.classList.remove('active');
viewBtn.textContent = 'View';
} else {
// Load and display content
const content = await loadContent(path);
const filename = path.split('/').pop();
const language = getLanguage(filename);
contentEl.innerHTML = `<pre><code class="language-${language}">${escapeHtml(content)}</code></pre>`;
hljs.highlightElement(contentEl.querySelector('code'));
fileItem.classList.add('viewing');
viewBtn.classList.add('active');
viewBtn.textContent = 'Hide';
}
}
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
function renderStats() {
let totalFiles = 0;
let totalCategories = Object.keys(EXAMPLES).length;
Object.values(EXAMPLES).forEach(cat => {
totalFiles += cat.files.length;
});
statsEl.innerHTML = `
<div class="stat">
<div class="stat-number">${totalFiles}</div>
<div class="stat-label">Templates</div>
</div>
<div class="stat">
<div class="stat-number">${totalCategories}</div>
<div class="stat-label">Categories</div>
</div>
<div class="stat">
<div class="stat-number">100%</div>
<div class="stat-label">Copy-Ready</div>
</div>
`;
}
function renderCatalog(filter = '') {
const filterLower = filter.toLowerCase();
let html = '';
let hasResults = false;
Object.entries(EXAMPLES).forEach(([categoryId, category]) => {
const filteredFiles = category.files.filter(file =>
file.name.toLowerCase().includes(filterLower) ||
file.description.toLowerCase().includes(filterLower) ||
categoryId.toLowerCase().includes(filterLower)
);
if (filteredFiles.length === 0) return;
hasResults = true;
const isExpanded = expandedCategories.has(categoryId) || filter !== '';
const categoryName = categoryId.replace('/', ' / ').replace(/(^|\s)\S/g, t => t.toUpperCase());
html += `
<div class="category ${isExpanded ? 'expanded' : ''}" data-category="${categoryId}">
<div class="category-header" onclick="toggleCategory('${categoryId}')">
<div class="category-title">
<span class="category-icon">${category.icon}</span>
<span>${categoryName}</span>
<span class="category-count">${filteredFiles.length}</span>
</div>
<span class="category-toggle">▼</span>
</div>
<div class="category-content">
<div class="category-description">${category.description}</div>
<ul class="file-list">
${filteredFiles.map(file => `
<li class="file-item" data-path="${file.path}">
<div class="file-header">
<div class="file-info">
<a class="file-name" href="${file.path}" target="_blank">${file.name}</a>
<div class="file-description">${file.description}</div>
</div>
<div class="file-actions">
<button class="btn btn-view" onclick="handleView('${file.path}', this)">View</button>
<button class="btn btn-copy" onclick="handleCopy('${file.path}', this)">Copy</button>
<button class="btn btn-download" onclick="downloadFile('${file.path}', '${file.name}')">↓</button>
</div>
</div>
<div class="file-content"></div>
</li>
`).join('')}
</ul>
</div>
</div>
`;
});
catalogEl.innerHTML = html;
noResultsEl.style.display = hasResults ? 'none' : 'block';
}
function toggleCategory(categoryId) {
if (expandedCategories.has(categoryId)) {
expandedCategories.delete(categoryId);
} else {
expandedCategories.add(categoryId);
}
renderCatalog(searchInput.value);
}
async function handleView(path, btn) {
const fileItem = btn.closest('.file-item');
const contentEl = fileItem.querySelector('.file-content');
await toggleView(path, contentEl, btn);
}
async function handleCopy(path, btn) {
const success = await copyToClipboard(path);
if (success) {
const originalText = btn.textContent;
btn.textContent = '✓';
btn.classList.add('copied');
setTimeout(() => {
btn.textContent = originalText;
btn.classList.remove('copied');
}, 1500);
}
}
// Event listeners
let debounceTimer;
searchInput.addEventListener('input', (e) => {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => {
renderCatalog(e.target.value);
}, 150);
});
// Keyboard shortcuts
document.addEventListener('keydown', (e) => {
if (e.key === '/' && document.activeElement !== searchInput) {
e.preventDefault();
searchInput.focus();
}
if (e.key === 'Escape') {
searchInput.blur();
searchInput.value = '';
renderCatalog('');
}
});
// Initialize
renderStats();
renderCatalog();
</script>
</body>
</html>