diff --git a/layers/templates/CtLayout01/index.vue b/layers/templates/CtLayout01/index.vue index 9f0ba6e..6e46fdb 100644 --- a/layers/templates/CtLayout01/index.vue +++ b/layers/templates/CtLayout01/index.vue @@ -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(``, 'i') + const match = html.match(commentRegex) + if (!match || !match[1]) return null + return resolveCustomUrl(match[1].trim()) + } + // HTML 주석에서 customTranslang JSON URL 추출 // 형식: + // 또는: (상대경로) const extractCustomTranslangUrl = (html: string): string | null => { - const commentRegex = //i - const match = html.match(commentRegex) - return match && match[1] ? match[1].trim() : null + return extractCommentUrl(html, 'customTranslang') } // JSON 파일을 fetch해서 i18n에 추가