feat: 이미지 최적화 옵션 추가(fetchpriority/srcset/sizes) (TDD)

- ExportOptions에 이미지 옵션 추가
- hero 이미지에 조건부 속성 렌더링
- 테스트: image.responsive.options.test.ts
- 전체 테스트 그린 유지
This commit is contained in:
2025-11-16 18:49:39 +09:00
parent 19a39230be
commit 396d0ac7a0
4 changed files with 65 additions and 2 deletions
+7 -1
View File
@@ -9,6 +9,9 @@ export type ExportOptions = {
robotsMeta?: string
imageLoading?: 'lazy' | 'eager'
imageDecoding?: 'async' | 'sync'
imageFetchPriority?: 'high' | 'low'
imageSrcset?: string
imageSizes?: string
}
function renderFaq(section: { props: { items: Array<{ q: string; a: string }> } }) {
@@ -125,6 +128,9 @@ function renderHero(section: { props: { heading: string; subheading?: string; im
const imageUrl = am ? am.rewriteUrl(imageUrlRaw) : imageUrlRaw
const loading = opts?.imageLoading ?? 'lazy'
const decoding = opts?.imageDecoding ?? 'async'
const fetchpriority = opts?.imageFetchPriority ? ` fetchpriority="${escapeHtml(opts.imageFetchPriority)}"` : ''
const srcset = opts?.imageSrcset ? ` srcset="${escapeHtml(opts.imageSrcset)}"` : ''
const sizes = opts?.imageSizes ? ` sizes="${escapeHtml(opts.imageSizes)}"` : ''
return `
<section class="hero" aria-labelledby="hero-heading">
<div class="container">
@@ -133,7 +139,7 @@ function renderHero(section: { props: { heading: string; subheading?: string; im
${subheading.length > 0 ? `<p>${escapeHtml(subheading)}</p>` : ''}
</div>
<div class="media">
<img src="${escapeHtml(imageUrl)}" alt="${escapeHtml(heading)}" loading="${escapeHtml(loading)}" decoding="${escapeHtml(decoding)}" width="1200" height="675" />
<img src="${escapeHtml(imageUrl)}" alt="${escapeHtml(heading)}" loading="${escapeHtml(loading)}" decoding="${escapeHtml(decoding)}"${fetchpriority}${srcset}${sizes} width="1200" height="675" />
</div>
</div>
</section>