refactor: CtLayout01 로그 staticUrl 추가
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
// Configuration
|
// Configuration
|
||||||
const runtimeConfig = useRuntimeConfig()
|
const runtimeConfig = useRuntimeConfig()
|
||||||
const staticUrl = runtimeConfig.public.staticUrl
|
const staticUrl = runtimeConfig.public.staticUrl
|
||||||
|
const runType = runtimeConfig.public.runType
|
||||||
|
|
||||||
// CSR에서만 fnCustomAction, fnCustomLog, fnCustomVideo 즉시 설정 (HTML 렌더링 전에 필요)
|
// CSR에서만 fnCustomAction, fnCustomLog, fnCustomVideo 즉시 설정 (HTML 렌더링 전에 필요)
|
||||||
// handleCustomAction, handleCustomLog, handleCustomVideo가 정의되기 전이므로 나중에 업데이트됨
|
// 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 추출
|
// HTML 주석에서 customTranslang JSON URL 추출
|
||||||
// 형식: <!-- customTranslang: https://example.com/translations.json -->
|
// 형식: <!-- customTranslang: https://example.com/translations.json -->
|
||||||
|
// 또는: <!-- customTranslang: /path/to/translations.json --> (상대경로)
|
||||||
const extractCustomTranslangUrl = (html: string): string | null => {
|
const extractCustomTranslangUrl = (html: string): string | null => {
|
||||||
const commentRegex = /<!--\s*customTranslang\s*:\s*([^\s]+)\s*-->/i
|
return extractCommentUrl(html, 'customTranslang')
|
||||||
const match = html.match(commentRegex)
|
|
||||||
return match && match[1] ? match[1].trim() : null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSON 파일을 fetch해서 i18n에 추가
|
// JSON 파일을 fetch해서 i18n에 추가
|
||||||
|
|||||||
Reference in New Issue
Block a user