Files
web_6ea_educo/seoul/components/InternalLinkHub.vue
T
2026-11-11 12:31:47 +09:00

317 lines
7.8 KiB
Vue

<template>
<nav class="internal-link-hub" aria-label="관내 학년·과목별 과외 바로가기">
<div class="hub-container">
<div class="hub-header">
<span class="hub-badge">내부 연계 허브</span>
<h3 class="hub-title">{{ regionDong }} 과외 탐색 및 인근 지역 바로가기</h3>
<p class="hub-desc">
{{ regionDong }} 관내 학년별·과목별 1:1 맞춤 수업 및 인근 지역의 상세 커리큘럼을 바로 확인하실 수 있습니다.
</p>
</div>
<div class="hub-grid">
<!-- 1. 같은 동의 다른 과목 링크 -->
<div class="hub-card">
<div class="card-head">
<i class="fa-solid fa-book-open card-icon"></i>
<h4 class="card-title">{{ regionDong }} {{ grade }} 과목별 과외</h4>
</div>
<div class="link-chips">
<NuxtLink
v-for="sub in subjects"
:key="sub.name"
:to="`/${encodeURIComponent(regionDong)}/${encodeURIComponent(grade)}/${encodeURIComponent(sub.name)}`"
class="chip-link"
:class="{ active: sub.name === subjectName }"
>
{{ regionDong }} {{ sub.name }}과외
</NuxtLink>
</div>
</div>
<!-- 2. 같은 동의 다른 학년 링크 및 동 대표 링크 -->
<div class="hub-card">
<div class="card-head">
<i class="fa-solid fa-graduation-cap card-icon"></i>
<h4 class="card-title">{{ regionDong }} {{ subjectName }} 학년별 과외</h4>
</div>
<div class="link-chips">
<NuxtLink
v-for="g in grades"
:key="g"
:to="`/${encodeURIComponent(regionDong)}/${encodeURIComponent(g)}/${encodeURIComponent(subjectName)}`"
class="chip-link"
:class="{ active: g === grade }"
>
{{ regionDong }} {{ g }} {{ subjectName }}
</NuxtLink>
<NuxtLink
:to="`/${encodeURIComponent(regionDong)}`"
class="chip-link"
>
{{ regionDong }} 초·중·고 과외 전체
</NuxtLink>
</div>
</div>
<!-- 3. 관내 인접 동 순환 링크 (Circular Sliding Window) -->
<div class="hub-card">
<div class="card-head">
<i class="fa-solid fa-location-dot card-icon"></i>
<h4 class="card-title">인근 주요 지역 {{ grade }} {{ subjectName }}</h4>
</div>
<div class="link-chips">
<NuxtLink
v-for="d in nearbyDongs"
:key="d"
:to="`/${encodeURIComponent(d)}/${encodeURIComponent(grade)}/${encodeURIComponent(subjectName)}`"
class="chip-link"
>
{{ d }} {{ subjectName }}과외
</NuxtLink>
</div>
</div>
</div>
<!-- 4. 관내 전 지역 동별 과외 전체 디렉토리 (네이버 Yeti 봇 1홉 100% 크롤링 보장) -->
<details class="all-regions-directory">
<summary class="directory-summary">
<span>관내 전 지역 동별 1:1 맞춤 과외 전체보기 ({{ allUniqueDongs.length }}개 지역 바로가기)</span>
<span class="dir-arrow">▼</span>
</summary>
<div class="directory-body">
<div class="link-chips">
<NuxtLink
v-for="d in allUniqueDongs"
:key="`sub-${d}`"
:to="`/${encodeURIComponent(d)}/${encodeURIComponent(grade)}/${encodeURIComponent(subjectName)}`"
class="chip-link dir-link"
:class="{ active: d === regionDong }"
>
{{ d }} {{ grade }} {{ subjectName }}과외
</NuxtLink>
<NuxtLink
v-for="d in allUniqueDongs"
:key="`main-${d}`"
:to="`/${encodeURIComponent(d)}`"
class="chip-link dir-link"
>
{{ d }} 과외
</NuxtLink>
</div>
</div>
</details>
</div>
</nav>
</template>
<script setup>
import { computed } from 'vue'
import regionsData from '../data/regions.json'
const props = defineProps({
regionDong: {
type: String,
required: true
},
grade: {
type: String,
default: '중학생'
},
subjectName: {
type: String,
default: '수학'
}
})
const subjects = [
{ name: '수학' },
{ name: '영어' },
{ name: '국어' },
{ name: '과학' },
{ name: '사회' }
]
const grades = ['초등학생', '중학생', '고등학생']
// 전체 중복 제거된 동 목록
const allUniqueDongs = computed(() => {
const allList = regionsData.list || []
return Array.from(new Set(allList.map(r => r.dong).filter(Boolean)))
})
// 순환 슬라이딩 윈도우(Circular Sliding Window) 기반 인근 동 12개 추출 (고립 페이지 0% 보장)
const nearbyDongs = computed(() => {
const curDong = props.regionDong
const uniqueDongs = allUniqueDongs.value
const total = uniqueDongs.length
if (total === 0) return []
const curIdx = uniqueDongs.indexOf(curDong)
const startIdx = curIdx >= 0 ? curIdx : 0
const result = []
for (let offset = 1; offset < total && result.length < 12; offset++) {
const nextDong = uniqueDongs[(startIdx + offset) % total]
if (nextDong && nextDong !== curDong) {
result.push(nextDong)
}
}
return result
})
</script>
<style scoped>
.internal-link-hub {
background: var(--bg-card, #ffffff);
border-top: 1px solid var(--border-color, #e2e8f0);
padding: 48px 16px 36px;
margin-top: 20px;
}
.hub-container {
max-width: 1080px;
margin: 0 auto;
}
.hub-header {
text-align: center;
margin-bottom: 32px;
}
.hub-badge {
display: inline-block;
font-size: 0.78rem;
font-weight: 700;
color: #2563eb;
background: rgba(37, 99, 235, 0.08);
padding: 4px 12px;
border-radius: 9999px;
margin-bottom: 8px;
}
.hub-title {
font-size: clamp(1.2rem, 3vw, 1.5rem);
font-weight: 800;
color: #1e293b;
margin: 0 0 8px;
}
.hub-desc {
font-size: 0.9rem;
color: #64748b;
margin: 0;
}
.hub-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 20px;
}
.hub-card {
background: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 12px;
padding: 20px;
}
.card-head {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 14px;
}
.card-icon {
color: #2563eb;
font-size: 1rem;
}
.card-title {
font-size: 1rem;
font-weight: 700;
color: #0f172a;
margin: 0;
}
.link-chips {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.chip-link {
display: inline-block;
font-size: 0.82rem;
font-weight: 600;
padding: 6px 12px;
background: #ffffff;
border: 1px solid #cbd5e1;
border-radius: 20px;
color: #334155;
text-decoration: none;
transition: all 0.2s ease;
}
.chip-link:hover {
background: #2563eb;
color: #ffffff;
border-color: #2563eb;
transform: translateY(-1px);
}
.chip-link.active {
background: #1e40af;
color: #ffffff;
border-color: #1e40af;
font-weight: 700;
}
.all-regions-directory {
margin-top: 20px;
background: #f8fafc;
border: 1px solid #e2e8f0;
border-radius: 12px;
overflow: hidden;
}
.directory-summary {
padding: 14px 20px;
font-size: 0.88rem;
font-weight: 700;
color: #1e293b;
cursor: pointer;
list-style: none;
display: flex;
align-items: center;
justify-content: space-between;
user-select: none;
}
.directory-summary::-webkit-details-marker {
display: none;
}
.dir-arrow {
font-size: 0.75rem;
color: #64748b;
transition: transform 0.2s ease;
}
details[open].all-regions-directory .dir-arrow {
transform: rotate(180deg);
}
.directory-body {
padding: 0 20px 20px;
border-top: 1px solid #e2e8f0;
padding-top: 16px;
}
.dir-link {
font-size: 0.76rem;
padding: 4px 10px;
}
</style>