refactor(website): SMI-1376 extract shared Skill types, utils, and ca…#1394
refactor(website): SMI-1376 extract shared Skill types, utils, and ca…#1394hytonylee wants to merge 2 commits into
Conversation
…tegories Add src/types/skills.ts (wire-format Skill, AlsoInstalled, SearchState), src/lib/skills-utils.ts (TRUST_BADGE_CLASSES, escapeHtml, formatNumber; re-exports getQualityTier/TIER_THRESHOLDS from quality-tiers), and src/data/categories.ts (CategoryMeta, SkillItem, CATEGORIES array lifted from [id].astro frontmatter). Extends env.d.ts with _rateLimitInterval and hideRateLimitToast window declarations. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
E2E Test Results
|
5ccd14b to
2d0b32d
Compare
Website PreviewDeploy failed. No preview URL was captured. View logs for details. |
2d0b32d to
5ccd14b
Compare
|
Thanks for this, @hytonylee — closing it after a detailed look during the June repo triage, with a clear path to redo it cleanly. Your original commit is preserved on the branch (restored to Why we're closing rather than mergingI rebased the branch onto
Path forward (tracked on #1376)The extraction is the right idea — it's just blocked on migrating those inline scripts to bundled One piece is independently good and worth keeping when #1376 is redone: extracting the inline 78-line Leaving #1376 open to redo cleanly after SMI-4907. Thanks again — the instinct to de-duplicate these pages is correct, just sequenced after the script migration. |
E2E Test Results
|
Summary
Extracts five helpers duplicated across
skills/index.astroandskills/[id].astrointo shared, typed modules, and converts both pages fromis:inlinescript blocks to bundler-visible<script>tags. This is the foundation ticket for the broader skills-directory refactor — subsequent tickets in the series depend on these types and utilities existing.Ticket
SMI-1376
Changes
src/types/skills.ts— wire-formatSkill(snake_case API response shape),AlsoInstalled,SearchStatediscriminated union, re-exportsQualityTiersrc/lib/skills-utils.ts—TRUST_BADGE_CLASSES,escapeHtml,formatNumber; re-exportsgetQualityTierandTIER_THRESHOLDSfrom the existingquality-tiers.tscanonical sourcesrc/data/categories.ts—CategoryMeta,SkillItem, andCATEGORIESarray lifted out of[id].astrofrontmattersrc/env.d.ts— adds_rateLimitIntervalandhideRateLimitToastto the globalWindowinterface (required for TypeScript to accept the rate-limit countdown logic)skills/index.astro— removesis:inline+define:vars, switches to bundled<script>with imports; SSR value (FEATURED_SKILL_IDS) passed via data attribute on a hidden config elementskills/[id].astro— same conversion;skillIdandCATEGORIES/CategoryMeta/SkillItemdefinitions replaced with imports; removes now-resolved SMI-4907 migration commentChecklist
Code Quality
npm run typecheck)npm run lint)npm test) — no behavioural logic changed; utilities are re-exports or thin wrappers with no branching to unit-testconsole.logstatements in production codeSecurity
escapeHtmlwas already the sanitisation boundary; no new user input surface addedMock Data Review (SMI-763)
tests/fixtures/)SKILLSMITH_USE_MOCK) controls mock vs real dataDocumentation
Testing
getQualityTier,formatNumber)npm run devsession insidepackages/website:/skills/skills/development(any category slug)/skills/<any-real-skill-id>E2E Tests (Required for MCP/Install changes)
Screenshots (if applicable)
N/A — refactor only, no visual changes.