diff --git a/lib/exporter/font.optimization.test.ts b/lib/exporter/font.optimization.test.ts new file mode 100644 index 0000000..f98d6fc --- /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('폰트 최적화', () => { + it('head에 Google Fonts preconnect 링크가 포함된다', () => { + const page = makePage() + const out = exportPage(page) + expect(out.html).toContain(' { + const page = makePage() + const out = exportPage(page) + expect(out.css).toMatch(/font-family:[^;]*system-ui/i) + }) +}) diff --git a/lib/exporter/html.ts b/lib/exporter/html.ts index 2c6cd0b..952bfc6 100644 --- a/lib/exporter/html.ts +++ b/lib/exporter/html.ts @@ -254,6 +254,7 @@ function buildHead(page: Page) { + ${escapeHtml(page.seo.title)}