From 76889080e842ec7b840ca9395ca6ead679c71602 Mon Sep 17 00:00:00 2001 From: Jaybe Date: Sat, 15 Nov 2025 08:11:50 +0900 Subject: [PATCH] =?UTF-8?q?feat(font):=20Google=20Fonts=20preconnect=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20system-ui=20=ED=8F=B4=EB=B0=B1?= =?UTF-8?q?=20TDD?= 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..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)}