diff --git a/layers/templates/CtLayout01/index.vue b/layers/templates/CtLayout01/index.vue index cef4121..f01867b 100644 --- a/layers/templates/CtLayout01/index.vue +++ b/layers/templates/CtLayout01/index.vue @@ -11,6 +11,9 @@ const { tm, locale } = useI18n() const customContainerRef = ref(null) const nuxtApp = useNuxtApp() + // Configuration + const runtimeConfig = useRuntimeConfig() + const staticUrl = runtimeConfig.public.staticUrl const coerceToString = (value: unknown): string => { if (typeof value === 'string') return value @@ -132,14 +135,37 @@ // custom_contents가 URL인지 확인하고 HTML 가져오기 watch( - () => props.components.custom_contents, - async (customContents) => { - if (!customContents) { + () => { + // 타입 가드: 단일 컴포넌트 패턴인지 확인 + if ('group_sets' in props.components) { + return null + } + const customContents = props.components.customContents + const firstGroup = customContents?.groups?.[0] + if (!firstGroup) { + return null + } + // res_path는 PageDataResourceGroup의 직접 속성 + // 또는 btn_info.detail.res_path 형태일 수 있음 + const resPath = (firstGroup as any).detail?.res_path + if (!resPath) { + return null + } + + // 문자열로 변환 + const resPathStr = String(resPath) + // 마지막에 "/contents" 또는 "contents"가 있으면 제거 + const cleanedResPath = resPathStr.replace(/\/?contents\/?$/, '') + return cleanedResPath + }, + async (cleanedResPath) => { + if (!cleanedResPath) { fetchedHtml.value = '' return } - const contentStr = typeof customContents === 'string' ? customContents : String(customContents) + const contentStr = typeof cleanedResPath === 'string' ? `${staticUrl}${cleanedResPath}/index.html` : String(`${staticUrl}${cleanedResPath}/index.html`) + console.log("🚀 ~ contentStr:", contentStr) let html = '' if (isUrl(contentStr)) { @@ -533,4 +559,4 @@ min-height: 20rem; background-color: #fff; } - \ No newline at end of file +