From df41aac2b1f47f4f26c07c1f022fae7e75c76470 Mon Sep 17 00:00:00 2001 From: Jaybe Date: Sat, 15 Nov 2025 00:41:48 +0900 Subject: [PATCH] =?UTF-8?q?feat(exporter):=20=ED=8F=B0=ED=8A=B8=20?= =?UTF-8?q?=EC=B5=9C=EC=A0=81=ED=99=94=20-=20preconnect(googleapis/gstatic?= =?UTF-8?q?)=20=EB=B0=8F=20system-ui=20=ED=8F=B4=EB=B0=B1=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/exporter/font.optimization.test.ts | 29 ++++++++++++++++++++++++++ lib/exporter/html.ts | 1 + 2 files changed, 30 insertions(+) create mode 100644 lib/exporter/font.optimization.test.ts 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)} +