Merge branch 'feature/20260120_gil_custom' into feature/20250213_all

This commit is contained in:
“hyeonggkim”
2026-02-11 19:44:08 +09:00

View File

@@ -27,6 +27,7 @@
// Configuration
const runtimeConfig = useRuntimeConfig()
const staticUrl = runtimeConfig.public.staticUrl
const runType = runtimeConfig.public.runType
// CSR에서만 fnCustomAction, fnCustomLog, fnCustomVideo 즉시 설정 (HTML 렌더링 전에 필요)
// handleCustomAction, handleCustomLog, handleCustomVideo가 정의되기 전이므로 나중에 업데이트됨
@@ -123,12 +124,27 @@
}
}
// URL 경로 변환: http/https면 그대로, 상대경로면 STATIC_URL + RUN_TYPE + url 형식으로 변환
const resolveCustomUrl = (url: string): string => {
if (/^https?:\/\//i.test(url)) {
return url
}
return `${staticUrl}/${runType}${url}`
}
// HTML 주석에서 URL 추출하는 공통 함수
const extractCommentUrl = (html: string, key: string): string | null => {
const commentRegex = new RegExp(`<!--\\s*${key}\\s*:\\s*([^\\s]+)\\s*-->`, 'i')
const match = html.match(commentRegex)
if (!match || !match[1]) return null
return resolveCustomUrl(match[1].trim())
}
// HTML 주석에서 customTranslang JSON URL 추출
// 형식: <!-- customTranslang: https://example.com/translations.json -->
// 또는: <!-- customTranslang: /path/to/translations.json --> (상대경로)
const extractCustomTranslangUrl = (html: string): string | null => {
const commentRegex = /<!--\s*customTranslang\s*:\s*([^\s]+)\s*-->/i
const match = html.match(commentRegex)
return match && match[1] ? match[1].trim() : null
return extractCommentUrl(html, 'customTranslang')
}
// JSON 파일을 fetch해서 i18n에 추가