feat(export): extras 오버라이드 지원(robots/manifest) TDD 및 구현
Auto PR / open-pr (push) Successful in 20s
Auto Label PR / add-automerge-label (pull_request) Successful in 7s
CI / test (pull_request) Successful in 1m7s

This commit is contained in:
2025-11-15 02:26:54 +09:00
parent dab1dbcc48
commit afd3b167ab
3 changed files with 76 additions and 2 deletions
+21 -2
View File
@@ -1,13 +1,25 @@
import type { Page } from '@/lib/schema/page'
type ExtrasOverrides = {
robotsText?: string
manifest?: Partial<{
name: string
short_name: string
start_url: string
display: string
theme_color: string
}>
}
// Sheets 템플릿 등 ZIP 루트/서브 경로에 포함할 추가 파일(extras)을 구성한다.
// - actionUrl이 비어있을 때만 Google Apps Script 템플릿을 포함한다.
export function buildExtrasForPage(page: Page): Record<string, Uint8Array> {
export function buildExtrasForPage(page: Page, overrides?: ExtrasOverrides): Record<string, Uint8Array> {
const extras: Record<string, Uint8Array> = {}
const te = new TextEncoder()
// Always provide a baseline robots.txt
const robots = `User-agent: *\nDisallow:`
const robotsDefault = `User-agent: *\nDisallow:`
const robots = overrides?.robotsText ?? robotsDefault
extras['robots.txt'] = te.encode(robots)
// Provide a minimal site.webmanifest derived from Page
@@ -20,6 +32,13 @@ export function buildExtrasForPage(page: Page): Record<string, Uint8Array> {
start_url: '/',
display: 'standalone',
theme_color: page.theme?.primaryColor ?? '#000000',
...((overrides?.manifest as object) || {}),
} as {
name: string
short_name: string
start_url: string
display: string
theme_color: string
}
extras['site.webmanifest'] = te.encode(JSON.stringify(manifest))
} catch {}