feat(exporter): SEO/Perf small improvements (canonical, lazy/async hero, dark token) + tests #5
@@ -160,6 +160,10 @@
|
||||
- 스킵링크 등 선행 포커서블 회피: Desktop 버튼에 명시적 `focus()`
|
||||
- 키보드 시나리오: Tab → Mobile 포커스 확인 → Space로 토글 → Shift+Tab → Enter
|
||||
|
||||
##### 추가 CI 결과(2025-11-14)
|
||||
- E2E a11y 스모크 추가: 포커스 아웃라인(3px solid, 브랜드 컬러), 스킵링크 탭 순서(main 포커스 이동)
|
||||
- Exporter JS에 스킵링크 클릭 시 `#main`에 `tabindex="-1"` 부여 후 `focus()` 처리 → CI 그린 통과
|
||||
|
||||
#### 머지 상태
|
||||
- 머지 방식: Squash and merge
|
||||
- 브랜치 정리: `feat/ci-verify-run` 삭제 완료
|
||||
@@ -237,6 +241,7 @@
|
||||
- [2025-11-13 22:55] BuilderClientPage 렌더 중 ref 접근 경고 / useRef.current를 렌더 중 참조하여 ESLint 경고 발생 / FormBuilderPanel 통합 시 `useRef(createFormStore())` 사용 / `useMemo(() => createFormStore(), [])`로 스토어 인스턴스 고정하고 `useSyncExternalStore`에 직접 주입하여 해결 / 렌더 중 ref 접근 금지 원칙 재확인
|
||||
- [2025-11-14 09:35] Vitest 로그에서 i18n 누락 메시지 경고 확인(en: `builder.action.addSelect/addRadio`, `builder.form.actionUrl/honeypot/minSeconds`) → `messages/en.json`에 키 존재 여부 점검 및 누락 보완 후 재실행, 모든 테스트 그린 유지
|
||||
- [2025-11-14 09:45] 프리뷰 텍스트 매칭 불안정으로 테스트 실패 → `data-testid` 기반 안정화(`preview-seo-title` 등) 및 텍스트 매칭 지점 `Title:`→`Locale:`로 조정, 전면 그린
|
||||
- [2025-11-14 20:30] E2E 실패: 스킵링크 활성화 후 main 포커스 미이동 → Exporter JS에 스킵링크 클릭 핸들러 추가(`tabindex=-1` + `focus()`) → 로컬/CI 모두 그린
|
||||
|
||||
## 의사결정 기록(ADR)
|
||||
- [YYYY-MM-DD] Next.js(App Router) 채택: 생태계/배포/서버리스/SEO 편의성.
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('Exporter a11y/responsive enhancements', () => {
|
||||
test('hero image alt derives from heading', () => {
|
||||
const out = exportPage(makePage())
|
||||
expect(out.html).toContain('<h1 id="hero-heading">Welcome</h1>')
|
||||
expect(out.html).toContain('<img src="https://example.com/img.png" alt="Welcome" />')
|
||||
expect(out.html).toMatch(/<img[^>]*src="https:\/\/example\.com\/img\.png"[^>]*alt="Welcome"[^>]*\/>/)
|
||||
})
|
||||
|
||||
test('responsive and a11y CSS tokens exist', () => {
|
||||
|
||||
@@ -108,7 +108,7 @@ function renderHero(section: { props: { heading: string; subheading?: string; im
|
||||
${subheading ? `<p>${escapeHtml(subheading)}</p>` : ''}
|
||||
</div>
|
||||
<div class="media">
|
||||
<img src="${escapeHtml(imageUrl)}" alt="${escapeHtml(heading)}" />
|
||||
<img src="${escapeHtml(imageUrl)}" alt="${escapeHtml(heading)}" loading="lazy" decoding="async" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -237,6 +237,7 @@ function buildHead(page: Page) {
|
||||
return `
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="canonical" href="/" />
|
||||
<title>${escapeHtml(page.seo.title)}</title>
|
||||
<meta name="description" content="${escapeHtml(page.seo.description)}" />
|
||||
<meta property="og:title" content="${escapeHtml(page.seo.title)}" />
|
||||
@@ -272,6 +273,7 @@ function buildCss(page: Page) {
|
||||
.testimonial blockquote{ margin:0; font-style:italic; color:#1f2937 }
|
||||
.testimonial figcaption{ color:#475569; margin-top:.25rem }
|
||||
@media (max-width: 640px){ .container{ padding: 1rem } h1{ font-size: 1.5rem } }
|
||||
@media (prefers-color-scheme: dark){ body{ color:#e5e7eb; background:#0b1020 } .feature-item{ background:#0f172a; border-color:#1f2937 } }
|
||||
@media (prefers-reduced-motion: reduce){ *{ transition: none !important; animation: none !important } }
|
||||
`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { exportPage } from '@/lib/exporter/html'
|
||||
import { pageSchema, type Page } from '@/lib/schema/page'
|
||||
|
||||
function makePage(): Page {
|
||||
return pageSchema.parse({
|
||||
title: 'SEO/Perf',
|
||||
locale: 'en',
|
||||
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
|
||||
sections: [
|
||||
{ type: 'hero', props: { heading: 'Welcome', subheading: 'Sub', imageUrl: 'https://img.example/hero.png' } },
|
||||
],
|
||||
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
||||
seo: { title: 'SEO', description: 'Desc' },
|
||||
})
|
||||
}
|
||||
|
||||
describe('Exporter - small SEO/Perf improvements', () => {
|
||||
it('includes canonical link and dark mode tokens; hero image lazy/async', () => {
|
||||
const out = exportPage(makePage())
|
||||
const html = out.html
|
||||
const css = out.css
|
||||
|
||||
// canonical link present in head
|
||||
expect(html).toMatch(/<link[^>]+rel="canonical"/)
|
||||
|
||||
// hero image has loading/decoding attributes
|
||||
expect(html).toMatch(/<img[^>]*loading="lazy"/)
|
||||
expect(html).toMatch(/<img[^>]*decoding="async"/)
|
||||
|
||||
// dark mode media query token exists
|
||||
expect(css).toMatch(/@media \(prefers-color-scheme: dark\)/)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user