feat(backend,site): NOL 수집 및 숙박 안내 구조화와 지역 콘텐츠 연동
수집한 객실·이용 정보가 발행 화면에 연결되지 않던 경로를 보완하고, 숙소 소개와 지역 맛집 표시를 개선한다. - NOL 브라우저 수집 어댑터와 수집·반영 스크립트 추가 - 크롤링 fact 즉시 노출 및 직접 입력·정정값 보호 - 이용안내 항목별 구조화와 기존 표 연결, 원문 UI 비표시 - 군산 한일옥 고정 등록과 지역 맛집 탐색·보강 경로 추가 - 숙소 소개 요약, 히어로 문구, 지역 콘텐츠·목업 표시 개선 검증: 작업 트리 기준 site 타입·린트·빌드 및 안내 렌더링 테스트 통과, PC·모바일 화면 확인. 스테이징 diff 공백 검사 통과. 사용자 요청에 따라 현재 스테이징된 55개 파일만 포함하며 미스테이징 문서·테스트 등은 제외.
This commit is contained in:
1 parent
67a1db3cb9
commit
a093921b62
55 files changed
+2325
-269
No files matched your search
@@ -43,57 +43,62 @@
|
||||
var items = catchphrases();
|
||||
if (items.length === 0) return;
|
||||
|
||||
/* ★ 대표 문구는 고정이고, 순환은 그 **아래 줄**에서 돈다 (2026-09-11 사장님 지시:
|
||||
"메인 모토는 고정으로 하고, 그 아래 계속 변동되는 모토가 돌아가는 방향").
|
||||
예전에는 대표 문구 자리를 통째로 갈아 끼워 "히로쓰 가옥 담 너머…" 가 5초 뒤 사라졌다 —
|
||||
숙소 이름 다음으로 남아야 할 한 줄이 첫 화면에서 지워지는 셈이었다. */
|
||||
var base = ((P.narrative && P.narrative.tagline) || '').trim();
|
||||
var node = null;
|
||||
var last = null;
|
||||
|
||||
/* ★ 노드를 들고 있지 않고 매번 찾는다.
|
||||
/* ★ 노드를 들고 있지 않고 매번 확인한다.
|
||||
이 목업은 payload 를 손으로 고친 것이라 구워진 마크업과 어긋나고, React 는 하이드레이션에
|
||||
실패하면 #root 를 **통째로 다시 그린다** — 그때 히어로의 <p> 가 새 노드로 바뀐다.
|
||||
한 번 잡아 둔 참조로 계속 쓰면 그 순간부터 아무 일도 안 일어나면서 오류도 안 난다. */
|
||||
function findNode() {
|
||||
var wanted = [base];
|
||||
if (last) wanted.push(last);
|
||||
실패하면 #root 를 **통째로 다시 그린다** — 대표 문구 <p> 가 새 노드로 바뀌고 그 아래 붙여 둔
|
||||
줄은 같이 사라진다. 한 번 잡아 둔 참조로 계속 쓰면 그 순간부터 아무 일도 안 일어나면서 오류도 안 난다. */
|
||||
function findTagline() {
|
||||
var candidates = document.querySelectorAll('#root p');
|
||||
for (var i = 0; i < candidates.length; i += 1) {
|
||||
if (wanted.indexOf(candidates[i].textContent.trim()) >= 0) return candidates[i];
|
||||
if (candidates[i].textContent.trim() === base) return candidates[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if (!findNode()) return;
|
||||
function ensureNode() {
|
||||
if (node && node.isConnected) return node;
|
||||
var tagline = findTagline();
|
||||
if (!tagline) return null;
|
||||
node = document.createElement('p');
|
||||
node.id = 'w4d-sub';
|
||||
node.className = 'w4d-sub measure';
|
||||
tagline.insertAdjacentElement('afterend', node);
|
||||
reserve();
|
||||
return node;
|
||||
}
|
||||
if (!base || !findTagline()) return;
|
||||
|
||||
/* 줄 높이를 **가장 긴 문구**에 맞춰 박는다. 히어로는 아래 정렬이라 이 줄이 한 줄↔두 줄을 오가면
|
||||
숙소 이름과 대표 문구가 통째로 위아래로 튄다. 지금 폭에서 문구를 다 재 보고 가장 높은 값을 쓴다. */
|
||||
function reserve() {
|
||||
var width = node.getBoundingClientRect().width;
|
||||
if (!width) return;
|
||||
var probe = node.cloneNode(false);
|
||||
probe.removeAttribute('id');
|
||||
probe.style.cssText = 'position:absolute;visibility:hidden;pointer-events:none;width:' + width + 'px';
|
||||
node.parentNode.appendChild(probe);
|
||||
var max = 0;
|
||||
items.forEach(function (it) {
|
||||
probe.textContent = it.text;
|
||||
max = Math.max(max, probe.getBoundingClientRect().height);
|
||||
});
|
||||
probe.remove();
|
||||
node.style.minHeight = Math.ceil(max) + 'px';
|
||||
}
|
||||
var resizeTimer = null;
|
||||
window.addEventListener('resize', function () {
|
||||
window.clearTimeout(resizeTimer);
|
||||
resizeTimer = window.setTimeout(function () { if (node && node.isConnected) reserve(); }, 200);
|
||||
});
|
||||
|
||||
var byKind = function (kind) {
|
||||
return items.filter(function (it) { return it.kind === kind; });
|
||||
};
|
||||
var weather = null; // 못 받아 오면 날씨 문장은 아예 순환에 넣지 않는다.
|
||||
var bag = [];
|
||||
var cycle = [];
|
||||
|
||||
function nextGeneral() {
|
||||
if (bag.length === 0) {
|
||||
bag = byKind('general').slice();
|
||||
for (var j = bag.length - 1; j > 0; j -= 1) {
|
||||
var k = Math.floor(Math.random() * (j + 1));
|
||||
var t = bag[j]; bag[j] = bag[k]; bag[k] = t;
|
||||
}
|
||||
}
|
||||
return bag.pop();
|
||||
}
|
||||
|
||||
function buildCycle() {
|
||||
var now = new Date();
|
||||
var month = now.getMonth() + 1;
|
||||
var season = SEASON_OF_MONTH[month - 1];
|
||||
var out = [nextGeneral()];
|
||||
out.push(pick(byKind('season').filter(function (it) { return it.season === season; })));
|
||||
out.push(nextGeneral());
|
||||
out.push(pick(byKind('month').filter(function (it) { return it.month === month; })));
|
||||
out.push(nextGeneral());
|
||||
if (weather) {
|
||||
out.push(pick(byKind('weather').filter(function (it) { return it.weather === weather; })));
|
||||
}
|
||||
return out.filter(Boolean);
|
||||
}
|
||||
function buildCycle() { return items.filter(function (item) { return item.kind === "general"; }); }
|
||||
|
||||
/* 문장 하나를 단어 칸으로 조립한다. innerHTML 을 안 쓰는 이유는 문구가 데이터라서다 —
|
||||
지금은 우리가 쓴 문장이지만, 이 자리는 나중에 서버가 채운다. */
|
||||
@@ -118,63 +123,32 @@
|
||||
}
|
||||
|
||||
function show(text) {
|
||||
last = text;
|
||||
var fresh = !(node && node.isConnected);
|
||||
if (!ensureNode()) return;
|
||||
if (REDUCED) { node.textContent = text; return; }
|
||||
var current = node.firstElementChild;
|
||||
if (current && current.classList.contains('w4d-line')) {
|
||||
current.classList.remove('w4d-line--in');
|
||||
current.classList.add('w4d-line--out');
|
||||
}
|
||||
// 새로 붙인 줄은 비어 있으니 나갈 문장이 없다 — 기다리지 않고 바로 세운다.
|
||||
window.setTimeout(function () {
|
||||
if (!node || !node.isConnected) node = findNode();
|
||||
if (!node) return;
|
||||
if (!ensureNode()) return;
|
||||
paint(text);
|
||||
}, 300);
|
||||
}, fresh ? 0 : 300);
|
||||
}
|
||||
|
||||
function tick() {
|
||||
if (!node || !node.isConnected) node = findNode();
|
||||
if (!node) return;
|
||||
if (cycle.length === 0) cycle = buildCycle();
|
||||
var next = cycle.shift();
|
||||
if (next && next.text) show(next.text);
|
||||
}
|
||||
|
||||
/* 날씨는 렌더러가 쓰는 그 엔드포인트로 받는다(같은 오리진). 실패하면 조용히 넘어간다 —
|
||||
날씨 문장 몇 개 때문에 순환이 멈추면 안 된다. */
|
||||
function refreshWeather() {
|
||||
var place = P.place || {};
|
||||
if (!place.regionCode || place.latitude == null) return;
|
||||
var query = 'region_code=' + encodeURIComponent(place.regionCode) +
|
||||
'&latitude=' + place.latitude + '&longitude=' + place.longitude;
|
||||
fetch('/v1/local/weather?' + query)
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (body) {
|
||||
if (!body || !body.weather) return;
|
||||
var code = Number(body.weather.weather_code);
|
||||
// 렌더러(use-live-weather.ts)와 같은 분류를 쓴다 — 갈리면 화면의 날씨와 문장이 어긋난다.
|
||||
weather = code === 0 ? '맑음'
|
||||
: code >= 1 && code <= 3 ? '구름많음'
|
||||
: code >= 50 && code <= 69 ? '비'
|
||||
: code >= 70 && code <= 79 ? '눈' : '흐림';
|
||||
})
|
||||
.catch(function () { /* 구운 값 그대로 둔다 */ });
|
||||
}
|
||||
|
||||
refreshWeather();
|
||||
window.setInterval(refreshWeather, 10 * 60 * 1000);
|
||||
// 구워진 줄 높이를 하한으로 박는다 — 문장이 짧아 한 줄이 되면 아래 단추가 위로 튄다.
|
||||
(function reserve() {
|
||||
var found = findNode();
|
||||
if (!found) return;
|
||||
var h = found.getBoundingClientRect().height;
|
||||
if (h > 0) found.style.minHeight = Math.ceil(h) + 'px';
|
||||
})();
|
||||
// 첫 문장은 구워진 그대로 5초 두고 시작한다 — 들어오자마자 글자가 바뀌면 읽던 것을 놓친다.
|
||||
// 대표 문구가 먼저 읽히고 나서 아래 줄이 선다 — 둘이 한꺼번에 뜨면 어느 쪽이 숙소의 한 줄인지 안 읽힌다.
|
||||
window.setTimeout(function () {
|
||||
tick();
|
||||
window.setInterval(tick, 7000);
|
||||
}, 5000);
|
||||
window.setInterval(function () { if (!document.hidden && !REDUCED) tick(); }, 6000);
|
||||
}, 1200);
|
||||
}
|
||||
|
||||
/* ══ ② 헤더 안 미니 플레이어 ═══════════════════════════════════════════════
|
||||
|
||||
@@ -14,88 +14,8 @@ from pathlib import Path
|
||||
|
||||
SP = Path(__file__).parent
|
||||
|
||||
# ── 캐치프레이즈 100개 ────────────────────────────────────────────────────────
|
||||
# 사실이 아니라 문구다(출처가 붙는 값이 아니다). 근거는 payload 의 시설·위치 값 —
|
||||
# 적산가옥 두 동 · 히로쓰 가옥 옆 · 마당과 정원 · 창고형 카페 · 매일 세탁하는 침구 · 최대 4인.
|
||||
GENERAL = [
|
||||
"백 년 된 집에서 하룻밤",
|
||||
"담 너머는 히로쓰 가옥입니다",
|
||||
"독채 두 동, 마당은 각자 씁니다",
|
||||
"기와 아래에서 아침을 맞습니다",
|
||||
"새소리로 눈이 떠지는 집",
|
||||
"골목이 조용해지는 시간에 도착하세요",
|
||||
"침구는 매일 새것처럼 나갑니다",
|
||||
"마당 평상에 앉으면 항구 소리가 들립니다",
|
||||
"1920년대에 지은 집, 지금 쓰는 집",
|
||||
"대문을 닫으면 골목이 멀어집니다",
|
||||
"창고를 고친 카페 공간이 딸려 있습니다",
|
||||
"밤에는 정원 석등만 켜 둡니다",
|
||||
"초원사진관까지 걸어서 3분",
|
||||
"원도심 한가운데, 차는 세워 두세요",
|
||||
"A동은 일본식, B동은 모던입니다",
|
||||
"네 사람까지 묶는 독채입니다",
|
||||
"오후 세 시부터 이 집은 손님 것입니다",
|
||||
"이 골목에서는 서두를 일이 없습니다",
|
||||
"백 년 된 기와가 비를 받습니다",
|
||||
"여행이라기보다 하루의 이사입니다",
|
||||
"군산에서 가장 조용한 담 안쪽",
|
||||
"이 집의 시간은 조금 느립니다",
|
||||
"마당, 정원, 그리고 평상 하나",
|
||||
"짐을 풀면 골목부터 걸어 보세요",
|
||||
"창을 열면 옆집 기와가 보입니다",
|
||||
"담배 냄새가 없는 집입니다",
|
||||
"이불에서 볕 냄새가 납니다",
|
||||
"두 동 모두 남의 인기척이 없습니다",
|
||||
"내항까지 걸어 십 분",
|
||||
"오래된 것을 고쳐 쓰는 집",
|
||||
"부엌이 있어 아침은 지어 드셔도 됩니다",
|
||||
"밤에는 골목 등만 남습니다",
|
||||
"백 년 된 집이 아직 손님을 받습니다",
|
||||
"개항장 골목의 끝집입니다",
|
||||
"문패보다 기와를 보고 찾아오세요",
|
||||
"걸어서 도는 여행에 알맞은 자리",
|
||||
"마루에 앉는 시간이 일정의 절반입니다",
|
||||
"좁은 골목 끝, 대문 하나",
|
||||
"여기서는 계획을 반쯤 접어도 됩니다",
|
||||
"하루를 통째로 쓰는 숙소",
|
||||
]
|
||||
SEASON = {
|
||||
"봄": ["정원에 꽃이 먼저 옵니다", "봄에는 대문을 열어 둡니다", "벚꽃 지는 골목을 걸어 오세요",
|
||||
"마당에 앉는 계절이 시작됩니다", "새소리가 가장 많은 철입니다", "창을 열면 봄이 방까지 들어옵니다"],
|
||||
"여름": ["처마 그늘이 가장 긴 계절입니다", "마당에 물을 뿌리면 시원해집니다", "여름 밤에는 평상이 제일 좋습니다",
|
||||
"창고형 카페가 낮에는 서늘합니다", "소나기는 기와가 받아 줍니다", "해가 길어 저녁이 넉넉합니다"],
|
||||
"가을": ["기와 위로 가을 볕이 마릅니다", "가을 바람이 담을 넘어옵니다", "가을 골목은 해가 빨리 눕습니다",
|
||||
"창을 열어 두고 자도 되는 밤입니다", "가을에는 평상이 가장 좋은 자리입니다", "마당에 잎이 떨어지는 계절입니다"],
|
||||
"겨울": ["기와에 눈이 앉으면 골목이 조용해집니다", "겨울 아침 마당은 서리 밭입니다", "이불 속에서 겨울 바람 소리를 듣습니다",
|
||||
"눈 오면 정원 석등만 켜 둡니다", "항구 바람이 매운 계절입니다", "겨울에는 카페 공간이 가장 아늑합니다"],
|
||||
}
|
||||
MONTH = {
|
||||
1: ["새해 첫 아침을 백 년 집에서", "겨울 골목이 가장 조용한 달입니다"],
|
||||
2: ["아직 바람이 찬 원도심입니다", "겨울 끝을 마당에서 봅니다"],
|
||||
3: ["정원에 첫 꽃이 오는 달입니다", "대문을 열어 두기 시작합니다"],
|
||||
4: ["벚꽃 지는 골목을 걷는 달입니다", "마당에 앉는 시간이 길어집니다"],
|
||||
5: ["새소리가 가장 많은 달입니다", "창을 열어 두고 자는 밤입니다"],
|
||||
6: ["처마 그늘이 길어지는 달입니다", "여름 앞의 원도심은 한가합니다"],
|
||||
7: ["소나기를 기와가 받는 달입니다", "여름 밤 평상이 제일 좋습니다"],
|
||||
8: ["낮에는 카페 공간이 서늘합니다", "해가 길어 저녁이 넉넉한 달입니다"],
|
||||
9: ["볕이 마르기 시작하는 달입니다", "가을이 담을 넘어오는 구월입니다"],
|
||||
10: ["잎이 마당에 떨어지는 달입니다", "걷기에 가장 좋은 달입니다"],
|
||||
11: ["해가 빨리 눕는 골목입니다", "이불이 가장 따뜻한 달입니다"],
|
||||
12: ["기와에 눈이 앉는 달입니다", "한 해의 끝을 조용히 보내는 자리"],
|
||||
}
|
||||
# 키는 렌더러(use-live-weather.ts)의 분류와 같아야 한다 — 맑음·구름많음·비·눈·흐림.
|
||||
WEATHER = {
|
||||
"맑음": ["마당 평상에 앉으면 새소리만 들립니다", "정원 쪽으로 그늘이 길게 눕는 시간입니다", "기와가 마르는 냄새가 납니다"],
|
||||
"구름많음": ["빛이 부드러운 날입니다", "골목 사진이 제일 잘 나오는 빛입니다"],
|
||||
"흐림": ["빛이 낮게 깔리는 날입니다", "이런 날은 카페 공간이 가장 아늑합니다"],
|
||||
"비": ["백 년 된 기와를 타고 내리는 소리가 다릅니다", "카페 공간에서 빗소리를 들으실 수 있습니다", "비 오는 골목에는 사람이 없습니다"],
|
||||
"눈": ["기와에 눈이 앉으면 골목이 통째로 조용해집니다", "눈 밟는 소리가 담 안에서 크게 들립니다"],
|
||||
}
|
||||
|
||||
items = [{"text": t, "kind": "general"} for t in GENERAL]
|
||||
items += [{"text": t, "kind": "season", "season": s} for s, lst in SEASON.items() for t in lst]
|
||||
items += [{"text": t, "kind": "month", "month": m} for m, lst in MONTH.items() for t in lst]
|
||||
items += [{"text": t, "kind": "weather", "weather": w} for w, lst in WEATHER.items() for t in lst]
|
||||
GENERAL = json.loads((SP.parents[1] / "src/lib/lodging-catchphrases.json").read_text(encoding="utf-8"))
|
||||
items = [{"text": text, "kind": "general"} for text in GENERAL]
|
||||
|
||||
payload = json.loads((SP / "stay-payload-new.json").read_text(encoding="utf-8"))
|
||||
payload["narrative"]["catchphrases"] = {"version": 1, "items": items}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {HeroCatchphrase} from '@site/sections/HeroCatchphrase';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {primaryImage} from '@site/seo/meta';
|
||||
import {
|
||||
@@ -97,7 +98,7 @@ export function Hero() {
|
||||
<div className="col-span-12 flex flex-col gap-5 px-4 py-8 sm:px-6 xl:col-span-4 xl:col-start-1 xl:row-start-1 xl:py-12 xl:pb-56 xl:pl-10 xl:pr-8">
|
||||
{tagline && (
|
||||
<p className="measure font-serif text-[length:var(--fs-lead)] leading-relaxed">
|
||||
{tagline}
|
||||
<HeroCatchphrase>{tagline}</HeroCatchphrase>
|
||||
</p>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {HeroCatchphrase} from '@site/sections/HeroCatchphrase';
|
||||
import type {CSSProperties, ReactNode} from 'react';
|
||||
import {isoDate} from '@site/lib/format';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
@@ -326,7 +327,7 @@ export function Shell({children}: {children: ReactNode}) {
|
||||
)}
|
||||
{slogan && (
|
||||
<p className="text-muted measure shrink-0 text-[length:var(--fs-xs)] leading-[1.9] sm:max-w-[18rem] sm:text-right">
|
||||
{slogan}
|
||||
<HeroCatchphrase>{slogan}</HeroCatchphrase>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {HeroCatchphrase} from '@site/sections/HeroCatchphrase';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {bookingActionLabel, bookingLinks, heroFacts, lowestPrice} from '@site/lib/derive';
|
||||
|
||||
@@ -87,7 +88,7 @@ export function Hero() {
|
||||
|
||||
{line && (
|
||||
<p className="measure mt-4 text-[length:var(--fs-lead)] font-medium leading-relaxed opacity-80">
|
||||
{line}
|
||||
<HeroCatchphrase>{line}</HeroCatchphrase>
|
||||
</p>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {HeroCatchphrase} from '@site/sections/HeroCatchphrase';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {bookingLabel, bookingLinks, unitSpec} from '@site/lib/derive';
|
||||
|
||||
@@ -275,7 +276,7 @@ export function Hero() {
|
||||
// 이름이 다 선 뒤에 한 박자 쉬고 따라온다. 동시에 뜨면 두 줄이 한 덩어리로 보인다.
|
||||
style={{animationDelay: '0.3s'}}
|
||||
>
|
||||
{subline}
|
||||
<HeroCatchphrase>{subline}</HeroCatchphrase>
|
||||
</p>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {HeroCatchphrase} from '@site/sections/HeroCatchphrase';
|
||||
import type {ReactNode} from 'react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {
|
||||
@@ -83,7 +84,7 @@ export function Shell({children}: {children: ReactNode}) {
|
||||
|
||||
{(narrative.tagline ?? narrative.heroSubline) && (
|
||||
<p className="text-muted mt-3 text-[length:var(--fs-sm)]" style={{lineHeight: 1.7}}>
|
||||
{narrative.tagline ?? narrative.heroSubline}
|
||||
<HeroCatchphrase>{narrative.tagline ?? narrative.heroSubline}</HeroCatchphrase>
|
||||
</p>
|
||||
)}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ export {publicLinks};
|
||||
*/
|
||||
|
||||
export interface InfoRow {
|
||||
key?: string;
|
||||
label: string;
|
||||
value: string;
|
||||
/** 부가 설명. 출처가 아니라 사장님이 붙인 보충 문구. */
|
||||
@@ -39,6 +40,7 @@ export function essentialRows(payload: SitePayload): InfoRow[] {
|
||||
return selectPublishable(payload.facts)
|
||||
.filter((fact) => fact.scope === 'place')
|
||||
.map((fact) => ({
|
||||
key: fact.key,
|
||||
label: displayFactLabel(fact),
|
||||
value: displayValue(fact, payload.facts),
|
||||
}))
|
||||
@@ -46,6 +48,8 @@ export function essentialRows(payload: SitePayload): InfoRow[] {
|
||||
}
|
||||
|
||||
function displayValue(fact: FactEntry, all: FactEntry[]): string {
|
||||
// 두 이용 정보 영역은 같은 소개 요약을 쓴다. 상세 소개와 다른 사실은 원문을 보존한다.
|
||||
if (fact.key === 'intro' && fact.summary?.trim()) return fact.summary.trim();
|
||||
const text = factText(all, fact.key);
|
||||
if (!text) return '';
|
||||
if (fact.type !== 'bool') return text;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
[
|
||||
"잠시 걸음을 멈추고 온전한 쉼을 마주하는 시간",
|
||||
"바쁜 일상을 내려놓고 나를 위한 여유를 담아갑니다",
|
||||
"여행의 길목에서 만나는 조용하고 편안한 머무름",
|
||||
"아무것도 하지 않아도 편안해지는 오늘의 휴식",
|
||||
"낯선 곳에서 느끼는 다정한 온기와 작은 쉼표",
|
||||
"지친 하루의 끝에 찾아오는 나만의 따뜻한 여백",
|
||||
"천천히 흘러가는 시간 속에서 마주하는 깊은 휴식",
|
||||
"스쳐 가는 여행 속에서 오래 기억될 아늑한 순간",
|
||||
"복잡한 생각은 잠시 잊고 편안하게 쉬어가세요",
|
||||
"작은 쉼이 모여 내일을 살아갈 따뜻한 힘이 됩니다"
|
||||
]
|
||||
@@ -1,3 +1,4 @@
|
||||
import {selectPublishable} from '@o2o/shared';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {factualSummary} from '@site/seo/meta';
|
||||
import {essentialRows} from '@site/lib/derive';
|
||||
@@ -17,7 +18,8 @@ import {formatKoreanDate} from '@site/lib/format';
|
||||
export function AnswerBlock() {
|
||||
const payload = useSite();
|
||||
const rows = essentialRows(payload).slice(0, 6);
|
||||
const summary = payload.narrative.summary ?? factualSummary(payload);
|
||||
const intro = selectPublishable(payload.facts).find((fact) => fact.key === 'intro');
|
||||
const summary = intro?.summary?.trim() || payload.narrative.summary || factualSummary(payload);
|
||||
|
||||
if (rows.length === 0 && !summary) return null;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {Phone} from 'lucide-react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {bookingActionLabel, bookingLinks, essentialRows, RULE_FACT_KEYS} from '@site/lib/derive';
|
||||
import {bookingActionLabel, bookingLinks, essentialRows} from '@site/lib/derive';
|
||||
import {formatKoreanDate} from '@site/lib/format';
|
||||
import type {InfoRow} from '@site/lib/derive';
|
||||
import {Section} from '@site/lib/ui';
|
||||
@@ -43,19 +43,45 @@ const RULE_LABELS = new Set([
|
||||
export function EssentialInfoSection() {
|
||||
const payload = useSite();
|
||||
const rows = essentialRows(payload);
|
||||
const guides = payload.links.filter((link) => link.confirmed &&
|
||||
[link.stayGuide?.policy, link.stayGuide?.service, link.stayGuide?.reservation].some((text) => text?.trim()));
|
||||
const structured = guides.flatMap((link) => link.stayGuide?.fields ?? []);
|
||||
const mergedRows = [...rows];
|
||||
const seen = new Set(rows.map((row) => row.key));
|
||||
for (const field of structured) {
|
||||
// 직접 입력한 노출값을 우선한다. 같은 항목을 출처마다 반복하지 않는다.
|
||||
if (!seen.has(field.key)) {
|
||||
mergedRows.push(field);
|
||||
seen.add(field.key);
|
||||
}
|
||||
}
|
||||
const isRule = (row: InfoRow) => {
|
||||
if (['cooking_allowed', 'smoking'].includes(row.key ?? '')) return false;
|
||||
return RULE_LABELS.has(row.label) || structured.some((field) => field.key === row.key && field.group === 'rules');
|
||||
};
|
||||
const hiddenCount = payload.facts.filter(
|
||||
(fact) => fact.scope === 'place' && !rows.some((row) => row.label === fact.label),
|
||||
).length;
|
||||
|
||||
if (rows.length === 0) return null;
|
||||
if (rows.length === 0 && guides.length === 0) return null;
|
||||
|
||||
/**
|
||||
* 규정과 나머지를 가른다.
|
||||
*
|
||||
* ★ 순서를 뒤집지 않는다 — 규정이 먼저다. 예약 전에 알아야 클레임이 안 난다.
|
||||
*/
|
||||
const ruleRows = rows.filter((row) => RULE_LABELS.has(row.label));
|
||||
const otherRows = rows.filter((row) => !RULE_LABELS.has(row.label));
|
||||
const ruleRows = [
|
||||
...mergedRows.filter(isRule),
|
||||
...guides.filter((link) => !link.stayGuide?.fields?.length && link.stayGuide?.policy).map((link) => ({
|
||||
label: 'NOL 이용 안내', value: link.stayGuide?.policy ?? '',
|
||||
})),
|
||||
];
|
||||
const otherRows = [
|
||||
...mergedRows.filter((row) => !isRule(row)),
|
||||
...guides.filter((link) => !link.stayGuide?.fields?.length && link.stayGuide?.service).map((link) => ({
|
||||
label: 'NOL 시설 안내', value: link.stayGuide?.service ?? '',
|
||||
})),
|
||||
];
|
||||
|
||||
return (
|
||||
<Section
|
||||
@@ -71,7 +97,7 @@ export function EssentialInfoSection() {
|
||||
<span>
|
||||
{hiddenCount > 0
|
||||
? `확인 중인 항목 ${hiddenCount}개는 표시하지 않았습니다. 필요하시면 전화로 문의해 주세요.`
|
||||
: '모든 항목이 사업자 확인을 거쳤습니다.'}
|
||||
: '등록 정보와 수집한 안내를 기준으로 표시합니다.'}
|
||||
</span>
|
||||
<span className="font-medium">{formatKoreanDate(payload.site.updatedAt)} 기준</span>
|
||||
</span>
|
||||
@@ -80,6 +106,11 @@ export function EssentialInfoSection() {
|
||||
<div className="space-y-8">
|
||||
{ruleRows.length > 0 && <Rows title="예약 전 확인" rows={ruleRows} emphasis />}
|
||||
{otherRows.length > 0 && <Rows title="시설 · 편의" rows={otherRows} />}
|
||||
{guides.filter((link) => link.stayGuide?.reservation).map((link) => (
|
||||
<Rows key={`reservation-${link.url}`} title="예약 공지" emphasis rows={[
|
||||
{label: 'NOL 예약 공지', value: link.stayGuide?.reservation ?? ''},
|
||||
]} />
|
||||
))}
|
||||
<BookingRow />
|
||||
</div>
|
||||
</Section>
|
||||
@@ -112,16 +143,16 @@ function Rows({title, rows, emphasis}: {title: string; rows: InfoRow[]; emphasis
|
||||
|
||||
{/* ★ 테두리는 판 하나에만 준다. 줄 사이는 선(divide)이지 상자가 아니다. */}
|
||||
<dl className="divide-line divide-y">
|
||||
{rows.map((row) => (
|
||||
{rows.map((row, index) => (
|
||||
<div
|
||||
key={row.label}
|
||||
key={`${row.label}-${index}`}
|
||||
className="flex flex-col gap-1 py-3.5 sm:flex-row sm:items-baseline sm:gap-6"
|
||||
>
|
||||
<dt className="text-muted text-[length:var(--fs-sm)] sm:w-40 sm:shrink-0">
|
||||
{row.label}
|
||||
</dt>
|
||||
{/* measure: 긴 규정 문장이 화면 끝까지 늘어나면 다음 줄 첫 글자를 못 찾는다. */}
|
||||
<dd className="measure text-[length:var(--fs-sm)] font-semibold">
|
||||
<dd className="measure min-w-0 whitespace-pre-line break-words text-[length:var(--fs-sm)] font-semibold">
|
||||
{row.value}
|
||||
{row.note && <span className="text-muted mt-0.5 block font-normal">{row.note}</span>}
|
||||
</dd>
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import {useEffect, useState, type CSSProperties} from 'react';
|
||||
import {PlaceCategory} from '@o2o/shared';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import lines from '@site/lib/lodging-catchphrases.json';
|
||||
import './hero-catchphrase.css';
|
||||
|
||||
export function HeroCatchphrase({children}: {children?: string}) {
|
||||
const {place} = useSite();
|
||||
const lodging = place.category === PlaceCategory.LODGING;
|
||||
const [index, setIndex] = useState(0);
|
||||
// 업장 소개는 첫 줄에 고정하고, 공통 감성 문구만 둘째 줄에서 순환한다.
|
||||
const phrases = lines;
|
||||
useEffect(() => {
|
||||
if (!lodging) return;
|
||||
const motion = window.matchMedia('(prefers-reduced-motion: reduce)');
|
||||
const timer = window.setInterval(() => {
|
||||
if (!document.hidden && !motion.matches) setIndex((value) => (value + 1) % phrases.length);
|
||||
}, 6000);
|
||||
return () => window.clearInterval(timer);
|
||||
}, [lodging, phrases.length]);
|
||||
|
||||
if (!lodging) return children;
|
||||
const text = phrases[index % phrases.length];
|
||||
return (
|
||||
<span className="hero-catchphrase">
|
||||
{children && <span className="hero-catchphrase-fixed">{children}</span>}
|
||||
<span className="w4d-line w4d-line--in" key={index}>
|
||||
{text.split(/\s+/).map((word, i) => (
|
||||
<span key={i}>{i > 0 && ' '}<span className="w4d-w"><span style={{'--w4d-d': `${i * 55}ms`} as CSSProperties}>{word}</span></span></span>
|
||||
))}
|
||||
</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import {HeroCatchphrase} from '@site/sections/HeroCatchphrase';
|
||||
import {useCallback, useEffect, useRef, useState} from 'react';
|
||||
import {ChevronLeft, ChevronRight, Phone} from 'lucide-react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
@@ -124,7 +125,7 @@ export function HeroPension() {
|
||||
</h1>
|
||||
{(narrative.tagline ?? narrative.heroSubline) && (
|
||||
<p className="measure mt-3 text-[length:var(--fs-lead)] leading-relaxed opacity-90">
|
||||
{narrative.tagline ?? narrative.heroSubline}
|
||||
<HeroCatchphrase>{narrative.tagline ?? narrative.heroSubline}</HeroCatchphrase>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {HeroCatchphrase} from '@site/sections/HeroCatchphrase';
|
||||
import {ChevronDown, MapPin} from 'lucide-react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {primaryImage} from '@site/seo/meta';
|
||||
@@ -99,7 +100,7 @@ export function HeroSection() {
|
||||
{/* ★ 한 줄이 없으면 요약이라도 세운다 — 이름만 덩그러니 있는 첫 화면은 안내가 아니다. */}
|
||||
{(narrative.tagline ?? narrative.heroSubline ?? narrative.summary) && (
|
||||
<p className="measure mt-3 text-[length:var(--fs-lead)] leading-relaxed opacity-85">
|
||||
{narrative.tagline ?? narrative.heroSubline ?? narrative.summary}
|
||||
<HeroCatchphrase>{narrative.tagline ?? narrative.heroSubline ?? narrative.summary}</HeroCatchphrase>
|
||||
</p>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {HeroCatchphrase} from '@site/sections/HeroCatchphrase';
|
||||
import {Phone} from 'lucide-react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {bookingActionLabel, bookingLinks, heroFacts, lowestPrice, placeRow} from '@site/lib/derive';
|
||||
@@ -59,7 +60,7 @@ export function HeroSplit() {
|
||||
{place.name}
|
||||
</h1>
|
||||
<p className="measure mt-3 text-[length:var(--fs-lead)] leading-relaxed opacity-80">
|
||||
{narrative.tagline ?? narrative.heroSubline ?? narrative.summary}
|
||||
<HeroCatchphrase>{narrative.tagline ?? narrative.heroSubline ?? narrative.summary}</HeroCatchphrase>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -47,6 +47,16 @@ function meters(text: string | undefined): number {
|
||||
return Number(m[1]) * (m[2].toLowerCase() === 'km' ? 1000 : 1);
|
||||
}
|
||||
|
||||
function distanceOf(place: LocalPlace): number {
|
||||
// 숫자가 없는 옛 payload만 표기 문자열로 복원한다.
|
||||
if (place.distanceMeters != null) {
|
||||
return Number.isFinite(place.distanceMeters) && place.distanceMeters >= 0
|
||||
? place.distanceMeters
|
||||
: Infinity;
|
||||
}
|
||||
return meters(place.distanceText);
|
||||
}
|
||||
|
||||
/**
|
||||
* 주변 정보.
|
||||
*
|
||||
@@ -68,11 +78,11 @@ export function LocalGuideSection() {
|
||||
|
||||
const all = [...local.restaurants, ...local.attractions];
|
||||
const count = (r: (typeof RANGES)[number]) =>
|
||||
all.filter((place) => r.test(meters(place.distanceText))).length;
|
||||
all.filter((place) => r.test(distanceOf(place))).length;
|
||||
// 비었거나 전체와 똑같은 탭은 세우지 않는다 — 눌러도 그대로인 탭은 고장으로 읽힌다.
|
||||
const ranges = RANGES.filter((r, i) => i === 0 || (count(r) > 0 && count(r) < all.length));
|
||||
const active = ranges.find((r) => r.id === range) ?? RANGES[0];
|
||||
const within = (place: LocalPlace) => active.test(meters(place.distanceText));
|
||||
const within = (place: LocalPlace) => active.test(distanceOf(place));
|
||||
|
||||
return (
|
||||
<Section
|
||||
@@ -201,7 +211,7 @@ function PlaceList({
|
||||
)}
|
||||
{/* 거리는 사진 위에 얹는다 — 손님이 카드에서 제일 먼저 찾는 값이다.
|
||||
★ 분을 앞에, 거리를 뒤에. 답이 '분'이고 'm' 는 그 근거다. */}
|
||||
{place.distanceText && (
|
||||
{(Number.isFinite(distanceOf(place)) || place.distanceText) && (
|
||||
<span
|
||||
className="absolute bottom-2 left-2 rounded-md px-2 py-0.5 text-[length:var(--fs-xs)] font-bold"
|
||||
style={{
|
||||
@@ -209,7 +219,7 @@ function PlaceList({
|
||||
color: 'var(--tpl-bg, #fff)',
|
||||
}}
|
||||
>
|
||||
{walkText(meters(place.distanceText)) ?? place.distanceText}
|
||||
{walkText(distanceOf(place)) ?? place.distanceText}
|
||||
<span className="ml-1 font-normal opacity-70">{place.distanceText}</span>
|
||||
</span>
|
||||
)}
|
||||
@@ -217,6 +227,9 @@ function PlaceList({
|
||||
|
||||
<span className="flex flex-1 flex-col gap-1 p-3.5">
|
||||
<span className="text-[length:var(--fs-sm)] font-bold">{place.name}</span>
|
||||
{place.location && (
|
||||
<span className="text-muted text-[length:var(--fs-xs)] break-words">{place.location}</span>
|
||||
)}
|
||||
{place.description && (
|
||||
<span className="text-muted line-clamp-3 text-[length:var(--fs-xs)] leading-relaxed">
|
||||
{place.description}
|
||||
@@ -245,10 +258,11 @@ function PlaceList({
|
||||
<span>
|
||||
{' '}
|
||||
{place.distanceText}
|
||||
{walkText(meters(place.distanceText)) && ` · ${walkText(meters(place.distanceText))}`}
|
||||
{walkText(distanceOf(place)) && ` · ${walkText(distanceOf(place))}`}
|
||||
</span>
|
||||
)}
|
||||
{place.description && <p>{place.description}</p>}
|
||||
{place.location && <p>{place.location}</p>}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
.hero-catchphrase { display: block; }
|
||||
.hero-catchphrase-fixed { display: block; }
|
||||
.hero-catchphrase .w4d-line { display: block; margin-top: 0.5rem; min-height: 1.5em; word-break: keep-all; }
|
||||
.hero-catchphrase .w4d-w { display: inline-block; overflow: hidden; vertical-align: bottom; }
|
||||
.hero-catchphrase .w4d-w > span { display: inline-block; animation: lodging-word-in 0.45s both; animation-delay: var(--w4d-d); }
|
||||
@keyframes lodging-word-in {
|
||||
from { opacity: 0; transform: translateY(100%); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.hero-catchphrase .w4d-w > span { animation: none; }
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import {expect, it} from 'vitest';
|
||||
import {renderToStaticMarkup} from 'react-dom/server';
|
||||
import {PlaceCategory} from '@o2o/shared';
|
||||
import {SiteProvider} from '@site/lib/site-context';
|
||||
import {MOONLIGHT_STAY_PAYLOAD} from '@site/fixtures/moonlight-stay';
|
||||
import lines from '@site/lib/lodging-catchphrases.json';
|
||||
import {HeroCatchphrase} from './HeroCatchphrase';
|
||||
|
||||
it('keeps the original lodging tagline in the static HTML', () => {
|
||||
const html = renderToStaticMarkup(<SiteProvider payload={MOONLIGHT_STAY_PAYLOAD}><HeroCatchphrase>고유문구</HeroCatchphrase></SiteProvider>);
|
||||
expect(html).toContain('<span class="hero-catchphrase-fixed">고유문구</span>');
|
||||
expect(html).toContain('w4d-line--in');
|
||||
const text = html.replace(/<[^>]+>/g, '');
|
||||
expect(text).toContain('고유문구' + lines[0]);
|
||||
});
|
||||
|
||||
it('does not add lodging copy or controls to another category', () => {
|
||||
const payload = structuredClone(MOONLIGHT_STAY_PAYLOAD);
|
||||
payload.place.category = PlaceCategory.CAFE;
|
||||
const html = renderToStaticMarkup(<SiteProvider payload={payload}><HeroCatchphrase>카페 소개</HeroCatchphrase></SiteProvider>);
|
||||
expect(html).toBe('카페 소개');
|
||||
});
|
||||
|
||||
it('ships ten distinct short phrases', () => {
|
||||
expect(new Set(lines).size).toBe(10);
|
||||
expect(lines.every((line) => line.length >= 15 && line.length <= 30)).toBe(true);
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
import {expect, it} from 'vitest';
|
||||
import {renderToStaticMarkup} from 'react-dom/server';
|
||||
import {FactStatus, SourceType, type SitePayload} from '@o2o/shared';
|
||||
import {SiteProvider} from '@site/lib/site-context';
|
||||
import {MOONLIGHT_STAY_PAYLOAD} from '@site/fixtures/moonlight-stay';
|
||||
import {AnswerBlock} from './AnswerBlock';
|
||||
import {EssentialInfoSection} from './EssentialInfoSection';
|
||||
import {AboutSection} from './AboutSection';
|
||||
|
||||
function fixture(summary?: string): SitePayload {
|
||||
const payload = structuredClone(MOONLIGHT_STAY_PAYLOAD);
|
||||
payload.facts = [{
|
||||
key: 'intro', label: '숙소 소개', value: '숙소 소개 전체 원문입니다.', summary,
|
||||
scope: 'place', type: 'text', status: FactStatus.VERIFIED,
|
||||
sourceType: SourceType.LLM, critical: false, required: false,
|
||||
}];
|
||||
payload.narrative = {about: ['숙소 소개 전체 원문입니다.'], summary: '기존 첫 문장'};
|
||||
return payload;
|
||||
}
|
||||
|
||||
it('shows the same summary in both booking information sections', () => {
|
||||
const payload = fixture('짧게 요약한 숙소 소개');
|
||||
for (const section of [<AnswerBlock />, <EssentialInfoSection />]) {
|
||||
const html = renderToStaticMarkup(<SiteProvider payload={payload}>{section}</SiteProvider>);
|
||||
expect(html).toContain('짧게 요약한 숙소 소개');
|
||||
expect(html).not.toContain('숙소 소개 전체 원문입니다.');
|
||||
}
|
||||
const about = renderToStaticMarkup(<SiteProvider payload={payload}><AboutSection /></SiteProvider>);
|
||||
expect(about).toContain('숙소 소개 전체 원문입니다.');
|
||||
});
|
||||
|
||||
it.each([undefined, ' '])('keeps original text when summary is %s', (summary) => {
|
||||
const payload = fixture(summary);
|
||||
const html = renderToStaticMarkup(<SiteProvider payload={payload}><EssentialInfoSection /></SiteProvider>);
|
||||
expect(html).toContain('숙소 소개 전체 원문입니다.');
|
||||
});
|
||||
|
||||
it('does not expose summaries from unverified facts', () => {
|
||||
const payload = fixture('검증 안 된 요약');
|
||||
payload.facts[0].status = FactStatus.UNVERIFIED;
|
||||
for (const section of [<AnswerBlock />, <EssentialInfoSection />]) {
|
||||
const html = renderToStaticMarkup(<SiteProvider payload={payload}>{section}</SiteProvider>);
|
||||
expect(html).not.toContain('검증 안 된 요약');
|
||||
}
|
||||
});
|
||||
@@ -15,7 +15,6 @@ import {useState} from 'react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {sectionItems, sectionName} from '@site/lib/derive';
|
||||
import {SongsSection} from './SongsSection';
|
||||
import {DailySection} from './DailySection';
|
||||
import {PeopleSection} from './PeopleSection';
|
||||
import {ChronicleSection} from './ChronicleSection';
|
||||
import {PostcardSection} from './PostcardSection';
|
||||
@@ -30,7 +29,6 @@ const COUNT_WORD: Record<number, string> = {1: '한', 2: '두', 3: '세', 4: '
|
||||
|
||||
const TABS = [
|
||||
{id: 'songs', label: '가요 다방', Component: SongsSection},
|
||||
{id: 'daily', label: '오늘의 한 장', Component: DailySection},
|
||||
{id: 'people', label: '인물 열전', Component: PeopleSection},
|
||||
{id: 'chronicle', label: '시간의 골목', Component: ChronicleSection},
|
||||
{id: 'postcard', label: '오늘의 엽서', Component: PostcardSection},
|
||||
@@ -38,6 +36,7 @@ const TABS = [
|
||||
|
||||
export function StorySection() {
|
||||
const payload = useSite();
|
||||
const title = sectionName(payload, 'story', `${payload.place.addressLocality ?? '지역'} 이야기`);
|
||||
// 데이터가 있는 것만 탭이 된다 — 눌러서 빈 화면을 보게 하지 않는다.
|
||||
const tabs = TABS.filter((tab) => sectionItems(payload, tab.id).items.length > 0);
|
||||
const [active, setActive] = useState(0);
|
||||
@@ -65,13 +64,13 @@ export function StorySection() {
|
||||
>
|
||||
<div className="shell">
|
||||
<h2 id="story-heading" className="h2">
|
||||
{sectionName(payload, 'story', '군산 이야기')}
|
||||
{title}
|
||||
</h2>
|
||||
<p className="measure mt-3 text-[length:var(--fs-sm)] opacity-70">
|
||||
이 도시를 {COUNT_WORD[tabs.length] ?? `${tabs.length}`} 갈래로 봅니다. 하나씩 골라 보세요.
|
||||
</p>
|
||||
|
||||
<div className="mt-6 flex flex-wrap gap-1.5" role="tablist" aria-label="군산 이야기">
|
||||
<div className="mt-6 flex flex-wrap gap-1.5" role="tablist" aria-label={title}>
|
||||
{tabs.map((tab, index) => {
|
||||
const on = index === active;
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import {expect, it} from 'vitest';
|
||||
import {renderToStaticMarkup} from 'react-dom/server';
|
||||
import {SiteProvider} from '@site/lib/site-context';
|
||||
import {MOONLIGHT_STAY_PAYLOAD} from '@site/fixtures/moonlight-stay';
|
||||
import {LocalGuideSection} from './LocalGuideSection';
|
||||
|
||||
it('renders collected descriptions and addresses with numeric distance filters', () => {
|
||||
const payload = structuredClone(MOONLIGHT_STAY_PAYLOAD);
|
||||
payload.local.attractions = [];
|
||||
payload.local.restaurants = [
|
||||
{name: 'Cafe A', category: 'cafe', searchQuery: 'Cafe A', location: 'Address A',
|
||||
description: 'Collected description', distanceMeters: 401, distanceText: '400m'},
|
||||
{name: 'Cafe B', category: 'cafe', searchQuery: 'Cafe B', distanceMeters: 100},
|
||||
{name: 'Cafe C', category: 'cafe', searchQuery: 'Cafe C'},
|
||||
];
|
||||
const html = renderToStaticMarkup(<SiteProvider payload={payload}><LocalGuideSection /></SiteProvider>);
|
||||
expect(html).toContain('Collected description');
|
||||
expect(html).toContain('Address A');
|
||||
expect(html).toMatch(/걸어서 5분 이내 <span[^>]*>1<\/span>/);
|
||||
expect(html).toContain('Cafe C');
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
import {expect, it} from 'vitest';
|
||||
import {renderToStaticMarkup} from 'react-dom/server';
|
||||
import {sanitizePayloadForPublish, FactStatus, SourceType} from '@o2o/shared';
|
||||
import {SiteProvider} from '@site/lib/site-context';
|
||||
import {MOONLIGHT_STAY_PAYLOAD} from '@site/fixtures/moonlight-stay';
|
||||
import {EssentialInfoSection} from './EssentialInfoSection';
|
||||
|
||||
function fixture(confirmed = true) {
|
||||
const payload = structuredClone(MOONLIGHT_STAY_PAYLOAD);
|
||||
payload.facts = [];
|
||||
payload.links = [{
|
||||
channel: 1, title: 'NOL', url: 'https://nol.yanolja.com/stay/domestic/10068088', confirmed,
|
||||
stayGuide: {
|
||||
policy: '체크인 15:00 체크아웃 11:00\n전 연령 동일 1인당 2만원',
|
||||
service: '주방\n욕조',
|
||||
reservation: '- 반려동물 입실금지\n<script>alert(1)</script>',
|
||||
},
|
||||
}];
|
||||
return payload;
|
||||
}
|
||||
|
||||
it('renders guides without facts, before booking actions, preserving line breaks and escaping HTML', () => {
|
||||
const payload = fixture();
|
||||
const html = renderToStaticMarkup(<SiteProvider payload={payload}><EssentialInfoSection /></SiteProvider>);
|
||||
expect(html).toContain('예약 전 확인');
|
||||
expect(html).toContain('체크인 15:00 체크아웃 11:00\n전 연령 동일 1인당 2만원');
|
||||
expect(html).toContain('주방\n욕조');
|
||||
expect(html).toContain('반려동물 입실금지');
|
||||
expect(html).toContain('whitespace-pre-line');
|
||||
expect(html).toContain('<script>');
|
||||
expect(html).not.toContain('<script>');
|
||||
expect(html).not.toContain('모든 항목이 사업자 확인');
|
||||
expect(html.indexOf('반려동물 입실금지')).toBeLessThan(html.indexOf('예약은 아래로'));
|
||||
});
|
||||
|
||||
it('does not render or embed guides from unconfirmed links', () => {
|
||||
const payload = fixture(false);
|
||||
const html = renderToStaticMarkup(<SiteProvider payload={payload}><EssentialInfoSection /></SiteProvider>);
|
||||
expect(html).toBe('');
|
||||
expect(JSON.stringify(sanitizePayloadForPublish(payload))).not.toContain('반려동물 입실금지');
|
||||
});
|
||||
|
||||
it('supports older payloads without guides', () => {
|
||||
const payload = fixture();
|
||||
delete payload.links[0].stayGuide;
|
||||
expect(renderToStaticMarkup(<SiteProvider payload={payload}><EssentialInfoSection /></SiteProvider>)).toBe('');
|
||||
});
|
||||
|
||||
it('keeps structured rows and restrictions without the original disclosure or source link', () => {
|
||||
const payload = fixture();
|
||||
payload.facts = [{key: 'check_in_time', label: '체크인 시간', value: '16:00',
|
||||
scope: 'place', type: 'time', status: FactStatus.CORRECTED, sourceType: SourceType.OWNER,
|
||||
critical: true, required: true}];
|
||||
payload.links[0].stayGuide!.fields = [
|
||||
{key: 'check_in_time', label: '체크인 시간', value: '15:00', group: 'rules'},
|
||||
{key: 'extra_person_fee', label: '인원 추가 요금', value: '20,000원', note: '1인당 · 전 연령 동일', group: 'rules'},
|
||||
{key: 'cooking_allowed', label: '취사', value: '가능', note: '생선구이 조리금지', group: 'facilities'},
|
||||
];
|
||||
const html = renderToStaticMarkup(<SiteProvider payload={payload}><EssentialInfoSection /></SiteProvider>);
|
||||
expect(html.match(/체크인 시간/g)).toHaveLength(1);
|
||||
expect(html).toContain('16:00');
|
||||
expect(html).toContain('20,000원');
|
||||
expect(html).toContain('1인당 · 전 연령 동일');
|
||||
expect(html).toContain('생선구이 조리금지');
|
||||
expect(html).not.toContain('<details');
|
||||
expect(html).not.toContain('NOL 이용안내 · 시설 원문');
|
||||
expect(html).not.toContain('NOL 안내 원문');
|
||||
expect(html).not.toContain('체크인 15:00 체크아웃 11:00');
|
||||
expect(html).toContain('반려동물 입실금지');
|
||||
expect(html).toContain('예약은 아래로');
|
||||
});
|
||||
Reference in new issue
Block a user