Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c23cf3873 | |||
| cc2b3039a3 | |||
| 0561c5d63c |
@@ -124,7 +124,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="lazy" decoding="async" />
|
||||
<img src="${escapeHtml(imageUrl)}" alt="${escapeHtml(heading)}" loading="lazy" decoding="async" width="1200" height="675" />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -254,6 +254,9 @@ function buildHead(page: Page) {
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="canonical" href="/" />
|
||||
<link rel="manifest" href="/site.webmanifest" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="theme-color" content="${page.theme.primaryColor}" />
|
||||
<title>${escapeHtml(page.seo.title)}</title>
|
||||
<meta name="description" content="${escapeHtml(page.seo.description)}" />
|
||||
<meta property="og:title" content="${escapeHtml(page.seo.title)}" />
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
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: 'Head Links',
|
||||
locale: 'en',
|
||||
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
|
||||
sections: [],
|
||||
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
||||
seo: { title: 't', description: 'd' },
|
||||
})
|
||||
}
|
||||
|
||||
describe('Exporter - head 링크 토큰', () => {
|
||||
it('site.webmanifest 링크를 포함한다', () => {
|
||||
const out = exportPage(makePage())
|
||||
expect(out.html).toMatch(/<link rel="manifest" href="\/site\.webmanifest"\s*\/>/)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,31 @@
|
||||
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 2',
|
||||
locale: 'en',
|
||||
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
|
||||
sections: [
|
||||
{ type: 'hero', props: { heading: 'Hello', subheading: 'World', imageUrl: 'https://img.example/hero.png' } },
|
||||
],
|
||||
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
||||
seo: { title: 'SEO2', description: 'Desc2' },
|
||||
})
|
||||
}
|
||||
|
||||
describe('Exporter - theme-color meta and hero image intrinsic size', () => {
|
||||
it('includes theme-color meta using page.theme.primaryColor', () => {
|
||||
const out = exportPage(makePage())
|
||||
const html = out.html
|
||||
expect(html).toMatch(/<meta name="theme-color" content="#0ea5e9"\s*\/>/)
|
||||
})
|
||||
|
||||
it('renders hero image with width/height attributes for CLS reduction', () => {
|
||||
const out = exportPage(makePage())
|
||||
const html = out.html
|
||||
expect(html).toMatch(/<img[^>]*\swidth="[0-9]+"/)
|
||||
expect(html).toMatch(/<img[^>]*\sheight="[0-9]+"/)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,40 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import JSZip from 'jszip'
|
||||
import { exportPage } from '@/lib/exporter/html'
|
||||
import { buildZip } from '@/lib/exporter/zip'
|
||||
import { buildExtrasForPage } from '@/lib/exporter/extras'
|
||||
import { pageSchema, type Page } from '@/lib/schema/page'
|
||||
|
||||
function makePage(): Page {
|
||||
return pageSchema.parse({
|
||||
title: 'Phase5',
|
||||
locale: 'en',
|
||||
theme: { primaryColor: '#2563eb', fontFamily: 'Inter' },
|
||||
sections: [],
|
||||
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
||||
seo: { title: 't', description: 'd' },
|
||||
})
|
||||
}
|
||||
|
||||
describe('Export ZIP 검증 강화 5차: extras MIME/내용 검증', () => {
|
||||
it('robots.txt는 텍스트이고, site.webmanifest는 유효한 JSON이다', async () => {
|
||||
const page = makePage()
|
||||
const out = exportPage(page)
|
||||
const extras = buildExtrasForPage(page)
|
||||
|
||||
const zipBytes = await buildZip({ html: out.html, css: out.css, js: out.js, assets: {}, extras })
|
||||
const zip = await JSZip.loadAsync(zipBytes)
|
||||
|
||||
// robots.txt 존재 및 텍스트 확인
|
||||
expect(Object.keys(zip.files)).toContain('robots.txt')
|
||||
const robots = await zip.files['robots.txt'].async('string')
|
||||
expect(robots).toMatch(/User-agent: \*/) // baseline
|
||||
|
||||
// site.webmanifest 존재 및 JSON 파싱 가능
|
||||
expect(Object.keys(zip.files)).toContain('site.webmanifest')
|
||||
const manifestStr = await zip.files['site.webmanifest'].async('string')
|
||||
const parsed = JSON.parse(manifestStr)
|
||||
expect(parsed.start_url).toBe('/')
|
||||
expect(parsed.display).toBe('standalone')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user