feat(phase6): 자산 경로 구조 옵션(UI/미리보기/Export) + 폰트 preconnect 토글 + extras 자동 보강(robots/manifest) + 문서화
This commit is contained in:
+19
-3
@@ -17,7 +17,14 @@ function toBytes(s: string): Uint8Array {
|
||||
}
|
||||
|
||||
function buildRobots(base?: string): string {
|
||||
if (base && base.trim().length > 0) return base
|
||||
if (base && base.trim().length > 0) {
|
||||
const s = base.trim()
|
||||
if (/^User-agent:/i.test(s)) return s
|
||||
const lines = s.split(/\n+/).map((l) => l.trim()).filter((l) => l.length > 0)
|
||||
if (lines.length === 0) return 'User-agent: *\n'
|
||||
const disallowLines = lines.map((l) => (l.startsWith('Disallow:') ? l : `Disallow: ${l}`))
|
||||
return `User-agent: *\n${disallowLines.join('\n')}`
|
||||
}
|
||||
return 'User-agent: *\n'
|
||||
}
|
||||
|
||||
@@ -37,9 +44,18 @@ export function buildExtrasForPage(page: Page, overrides?: ExtrasOverrides): Rec
|
||||
const robotsText = buildRobots(overrides?.robotsText)
|
||||
out['robots.txt'] = toBytes(robotsText)
|
||||
|
||||
// site.webmanifest
|
||||
// site.webmanifest (auto-enrich and safe-merge)
|
||||
const manifestBase = deriveManifest(page)
|
||||
const manifestMerged = { ...manifestBase, ...(overrides?.manifest || {}) }
|
||||
const ov = overrides?.manifest || {}
|
||||
const name = ov.name && ov.name.trim().length > 0 ? ov.name : manifestBase.name
|
||||
const short_name = ov.short_name && ov.short_name.trim().length > 0
|
||||
? ov.short_name
|
||||
: (name.length > 12 ? name.slice(0, 12) : name)
|
||||
const start_url = ov.start_url && ov.start_url.trim().length > 0 ? ov.start_url : manifestBase.start_url
|
||||
const display = ov.display && ov.display.trim().length > 0 ? ov.display : manifestBase.display
|
||||
const hexOk = ov.theme_color ? /^#([0-9a-fA-F]{3}){1,2}$/.test(ov.theme_color) : false
|
||||
const theme_color = hexOk ? (ov.theme_color as string) : manifestBase.theme_color
|
||||
const manifestMerged = { name, short_name, start_url, display, theme_color }
|
||||
const manifestJson = JSON.stringify(manifestMerged, null, 2)
|
||||
out['site.webmanifest'] = toBytes(manifestJson)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user