차량 모니터 복귀 링크 경로 정리

This commit is contained in:
seo
2026-07-01 00:55:28 +09:00
parent 783035deee
commit dba2c74d9e
2 changed files with 83 additions and 2 deletions
+80 -1
View File
@@ -956,6 +956,10 @@ car_monitor_require_access(false);
line-height: 1;
text-decoration: none;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
max-width: min(44vw, 260px);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.blog-back-link:hover,
.blog-back-link:focus {
@@ -1368,7 +1372,7 @@ car_monitor_require_access(false);
<i class="fas fa-car"></i>
</div>
<div>
<a href="/blog" class="blog-back-link"><span class="backArrow"></span> 블로그</a>
<a href="https://chaegeon.com/blog" id="blogBackLink" class="blog-back-link"><span class="backArrow"></span> 블로그</a>
<div class="d-flex align-items-center gap-2">
<div class="app-title" data-i18n="appTitle">Car Monitor</div>
<span id="live-badge" class="badge bg-secondary bg-opacity-10 text-secondary border border-secondary border-opacity-20 rounded-pill" style="font-size:0.6rem; vertical-align: top;">WAIT</span>
@@ -1822,8 +1826,15 @@ car_monitor_require_access(false);
let wakeLockWanted = false;
let latestDashboardData = null;
let latestDashboardMeta = null;
const FALLBACK_BACK_TARGET = 'https://chaegeon.com/blog';
const BACK_LINK_PATH_TITLE = {
'/': '채건닷컴',
'/home': '홈',
'/blog': '블로그',
};
document.addEventListener('DOMContentLoaded', () => {
setupBackLink();
initLanguage();
initTheme();
initWakeLock();
@@ -1858,6 +1869,74 @@ car_monitor_require_access(false);
return I18N[currentLang]?.[key] || I18N.en[key] || key;
}
function cleanPageTitle(title) {
return String(title || '')
.replace(/^채건닷컴\s*-\s*/i, '')
.replace(/\s*-\s*채건닷컴$/i, '')
.trim();
}
function sameSiteUrl(url) {
try {
const parsed = new URL(url, location.href);
return parsed.hostname === location.hostname || parsed.hostname.endsWith('.chaegeon.com') || parsed.hostname === 'chaegeon.com'
? parsed
: null;
} catch (e) {
return null;
}
}
function titleFromBackUrl(url) {
const parsed = sameSiteUrl(url);
if (!parsed) return '';
return BACK_LINK_PATH_TITLE[parsed.pathname.replace(/\/$/, '') || '/'] || cleanPageTitle(parsed.pathname.split('/').filter(Boolean).pop() || '');
}
function updateBackLinkLabel(label) {
const link = document.getElementById('blogBackLink');
if (!link) return;
link.innerHTML = `<span class="backArrow"></span> ${label}`;
}
async function resolveBackTarget() {
const ref = sameSiteUrl(document.referrer || '');
const current = new URL(location.href);
const target = ref && ref.href !== current.href ? ref.href : FALLBACK_BACK_TARGET;
let label = titleFromBackUrl(target);
if (ref && ref.origin === location.origin) {
try {
const res = await fetch(ref.href, { credentials: 'same-origin', cache: 'force-cache' });
if (res.ok) {
const html = await res.text();
const doc = new DOMParser().parseFromString(html, 'text/html');
label = cleanPageTitle(doc.querySelector('title')?.textContent) || label;
}
} catch (e) {}
}
return { href: target, label: label || '블로그' };
}
function setupBackLink() {
const link = document.getElementById('blogBackLink');
if (!link) return;
link.href = FALLBACK_BACK_TARGET;
updateBackLinkLabel('블로그');
resolveBackTarget().then(({ href, label }) => {
link.href = href;
updateBackLinkLabel(label);
});
link.addEventListener('click', (event) => {
event.preventDefault();
location.href = link.href || FALLBACK_BACK_TARGET;
});
}
function applyLanguage() {
document.documentElement.setAttribute('lang', currentLang);
document.title = t('appTitle');