diff --git a/lib/exporter/font.optimization.test.ts b/lib/exporter/font.optimization.test.ts new file mode 100644 index 0000000..de7a852 --- /dev/null +++ b/lib/exporter/font.optimization.test.ts @@ -0,0 +1,29 @@ +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: 'Font Opt', + locale: 'en', + theme: { primaryColor: '#2563eb', fontFamily: 'Inter' }, + sections: [ { type: 'hero', props: { heading: 'Hello', subheading: 'World', imageUrl: 'https://img/h.png' } } ], + form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } }, + seo: { title: 't', description: 'd' }, + }) +} + +describe('Exporter - 폰트 최적화', () => { + it('head에 폰트 preconnect 링크가 포함된다(googleapis/gstatic)', () => { + const out = exportPage(makePage()) + const html = out.html + expect(html).toMatch(//) + expect(html).toMatch(//) + }) + + it('CSS에 system-ui 폴백이 포함된다', () => { + const out = exportPage(makePage()) + const css = out.css + expect(css).toMatch(/font-family:[^;]*system-ui/i) + }) +}) diff --git a/lib/exporter/html.ts b/lib/exporter/html.ts index 2c6cd0b..4ff9c78 100644 --- a/lib/exporter/html.ts +++ b/lib/exporter/html.ts @@ -336,6 +336,7 @@ export function exportPage(page: Page, opts?: ExportOptions): Exported {
${buildHead(page)} +