[feat] solution: 날씨 조건 세분화,
공식채널 단일화, 한일옥 거리 반영 날씨 조건을 7종으로 세분화, 축제 종료 여부와 무관하게 상시 노출, '지역 읽기'갈래 축소, 야놀자(NOL) 브랜드명 제거.
This commit is contained in:
1 parent
29af37f158
commit
1f26bc7065
23 files changed
+421
-185
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import {useEffect, useState, type ReactNode} from 'react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {bookingActionLabel, bookingLinks, channelLabel} from '@site/lib/derive';
|
||||
import {bookingActionLabel, bookingLinks, channelLabel, primaryChannelLink} from '@site/lib/derive';
|
||||
import {formatKoreanDate, isoDate} from '@site/lib/format';
|
||||
// 배럴(@/sections)이 아니라 파일을 직접 가리킨다 — 배럴을 타면 섹션 전부가 딸려 온다.
|
||||
import {MobileTabBar} from '@site/sections/MobileTabBar';
|
||||
@@ -22,8 +22,8 @@ export function Shell({children}: {children: ReactNode}) {
|
||||
const index = useSectionIndex();
|
||||
const active = useActiveSection(index);
|
||||
const booking = bookingLinks(payload)[0];
|
||||
// 확정된 링크만 — 확정 전 URL 은 동명 업소일 수 있다.
|
||||
const links = payload.links.filter((link) => link.confirmed);
|
||||
// ★ 확정 채널을 전부 늘어놓지 않는다 — 예약 우선으로 딱 하나만 낸다(seo/jsonld.ts 주석 참고).
|
||||
const link = primaryChannelLink(payload);
|
||||
const address = place.roadAddress ?? place.address;
|
||||
|
||||
return (
|
||||
@@ -146,21 +146,19 @@ export function Shell({children}: {children: ReactNode}) {
|
||||
)}
|
||||
</address>
|
||||
|
||||
{links.length > 0 && (
|
||||
{link && (
|
||||
<nav aria-label="공식 채널" className="md:col-span-3">
|
||||
<ul className="space-y-1.5 text-[length:var(--fs-sm)]">
|
||||
{links.map((link) => (
|
||||
<li key={link.url}>
|
||||
<a
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="underline underline-offset-4 opacity-80 transition-opacity hover:opacity-100"
|
||||
>
|
||||
{channelLabel(link)}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
<li>
|
||||
<a
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="underline underline-offset-4 opacity-80 transition-opacity hover:opacity-100"
|
||||
>
|
||||
{channelLabel(link)}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
)}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
heroFacts,
|
||||
isSectionEnabled,
|
||||
lowestPrice,
|
||||
primaryChannelLink,
|
||||
unitSpec,
|
||||
} from '@site/lib/derive';
|
||||
import {formatKoreanDate, isoDate} from '@site/lib/format';
|
||||
@@ -40,9 +41,8 @@ export function Shell({children}: {children: ReactNode}) {
|
||||
const price = lowestPrice(payload);
|
||||
const facts = heroFacts(payload);
|
||||
const booking = bookingLinks(payload)[0];
|
||||
// ★ 확정된 링크 전부다. contactLinks() 는 말을 걸 수 있는 곳(네이버·인스타)만 남기는데,
|
||||
// 이 칼럼은 문의 창구가 아니라 **채널 목록**이라 블로그·공식 채널도 여기 선다.
|
||||
const links = payload.links.filter((link) => link.confirmed);
|
||||
// ★ 확정 채널을 전부 늘어놓지 않는다 — 예약 우선으로 딱 하나만 낸다(seo/jsonld.ts 주석 참고).
|
||||
const link = primaryChannelLink(payload);
|
||||
const address = place.roadAddress ?? place.address;
|
||||
|
||||
const menu = [
|
||||
@@ -145,21 +145,19 @@ export function Shell({children}: {children: ReactNode}) {
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
{links.length > 0 && (
|
||||
{link && (
|
||||
<nav aria-label="공식 채널" className="mt-12">
|
||||
<ul className="space-y-0.5">
|
||||
{links.map((link) => (
|
||||
<li key={link.url}>
|
||||
<a
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-muted flex min-h-[2rem] items-center text-[length:var(--fs-xs)] underline-offset-4 transition-colors hover:text-current hover:underline"
|
||||
>
|
||||
{channelLabel(link)}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
<li>
|
||||
<a
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-muted flex min-h-[2rem] items-center text-[length:var(--fs-xs)] underline-offset-4 transition-colors hover:text-current hover:underline"
|
||||
>
|
||||
{channelLabel(link)}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
)}
|
||||
|
||||
@@ -15,10 +15,10 @@ import {
|
||||
type WeatherBand,
|
||||
type WeatherMood,
|
||||
} from '@o2o/shared';
|
||||
import {BOOKING_CHANNELS, UNIT_SPEC, publicLinks, unitBaseRate} from '@site/seo/jsonld';
|
||||
import {UNIT_SPEC, bookingChannelLinks, primaryChannelLink, publicLinks, unitBaseRate} from '@site/seo/jsonld';
|
||||
|
||||
// 링크 거르기는 jsonld 에 산다(순환 의존 회피) — 화면 쪽은 늘 derive 를 통해 쓰므로 여기서 다시 낸다.
|
||||
export {publicLinks};
|
||||
export {publicLinks, primaryChannelLink};
|
||||
|
||||
/**
|
||||
* payload → 화면이 바로 쓰는 모양.
|
||||
@@ -477,23 +477,10 @@ function confirmedLinks(payload: SitePayload, channels: readonly number[]): Chan
|
||||
* 예약 버튼에 낼 채널. **BOOKING_CHANNELS 순서대로** 정렬한다 — 예약 화면으로 바로 가는
|
||||
* 채널이 맨 위 버튼이어야 한다.
|
||||
*
|
||||
* ★ 검색 결과 주소는 뺀다. 자동 발견이 `map.naver.com/p/search/…` 를 물어오는 경우가 있고
|
||||
* (실측 2026-09-08), 그걸 "예약" 버튼에 걸면 손님이 검색 화면을 만난다 — 예약하러 온
|
||||
* 사람에게 검색 결과를 주는 건 링크가 없는 것보다 나쁘다. 가게를 특정하지 못하는 주소라
|
||||
* 애초에 예약 창구가 아니다.
|
||||
* ★ 필터·순서 판단은 seo/jsonld 에 산다(순환 의존 회피, `bookingChannelLinks`) — 화면과
|
||||
* makesOffer.url·potentialAction 이 같은 함수를 써야 어긋나지 않는다.
|
||||
*/
|
||||
export function bookingLinks(payload: SitePayload): ChannelLink[] {
|
||||
const order = new Map(BOOKING_CHANNELS.map((channel, index) => [channel, index]));
|
||||
return confirmedLinks(payload, BOOKING_CHANNELS)
|
||||
.filter((link) => !isSearchUrl(link.url))
|
||||
.sort((a, b) => (order.get(a.channel) ?? 99) - (order.get(b.channel) ?? 99));
|
||||
}
|
||||
|
||||
/** 가게가 아니라 **검색 결과**를 가리키는 주소인지. */
|
||||
function isSearchUrl(url: string): boolean {
|
||||
return /\/p\/search\/|[?&]query=/.test(url);
|
||||
}
|
||||
|
||||
export const bookingLinks = bookingChannelLinks;
|
||||
|
||||
/**
|
||||
* ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import {expect, it} from 'vitest';
|
||||
import {condition} from './use-live-weather';
|
||||
|
||||
it('recognizes fog, showers and thunderstorms as distinct conditions', () => {
|
||||
expect(condition(45)).toBe('안개');
|
||||
expect(condition(48)).toBe('안개');
|
||||
expect(condition(80)).toBe('소나기');
|
||||
expect(condition(81)).toBe('소나기');
|
||||
expect(condition(82)).toBe('소나기');
|
||||
expect(condition(85)).toBe('소나기');
|
||||
expect(condition(86)).toBe('소나기');
|
||||
expect(condition(95)).toBe('뇌우');
|
||||
expect(condition(96)).toBe('뇌우');
|
||||
expect(condition(99)).toBe('뇌우');
|
||||
});
|
||||
|
||||
it('splits rain into drizzle, normal, heavy and freezing', () => {
|
||||
expect(condition(51)).toBe('이슬비');
|
||||
expect(condition(53)).toBe('이슬비');
|
||||
expect(condition(55)).toBe('이슬비');
|
||||
expect(condition(61)).toBe('비');
|
||||
expect(condition(63)).toBe('비');
|
||||
expect(condition(65)).toBe('강한비');
|
||||
expect(condition(56)).toBe('어는비');
|
||||
expect(condition(57)).toBe('어는비');
|
||||
expect(condition(66)).toBe('어는비');
|
||||
expect(condition(67)).toBe('어는비');
|
||||
});
|
||||
@@ -5,11 +5,18 @@ export interface LiveWeather extends WeatherSnapshot {
|
||||
stale?: boolean;
|
||||
}
|
||||
|
||||
function condition(code: number): string {
|
||||
/** WMO weather code → 한 줄. ★ solution/backend/services/site_payload.py 의 _weather_condition() 과 같은 구간이어야 한다. */
|
||||
export function condition(code: number): string {
|
||||
if (code === 0) return '맑음';
|
||||
if (code >= 1 && code <= 3) return '구름많음';
|
||||
if (code >= 50 && code <= 69) return '비';
|
||||
if (code === 45 || code === 48) return '안개';
|
||||
if (code === 51 || code === 53 || code === 55) return '이슬비';
|
||||
if (code === 56 || code === 57 || code === 66 || code === 67) return '어는비';
|
||||
if (code === 61 || code === 63) return '비';
|
||||
if (code === 65) return '강한비';
|
||||
if (code >= 70 && code <= 79) return '눈';
|
||||
if (code === 80 || code === 81 || code === 82 || code === 85 || code === 86) return '소나기';
|
||||
if (code >= 95 && code <= 99) return '뇌우';
|
||||
return '흐림';
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import {ExternalLink, Mail, MapPin, Phone} from 'lucide-react';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {isoDate} from '@site/lib/format';
|
||||
// 채널 이름표는 예약·문의 섹션과 같은 표를 쓴다 — 같은 채널이 자리마다 다른 이름으로 뜨면 안 된다.
|
||||
import {channelLabel, publicLinks} from '@site/lib/derive';
|
||||
import {channelLabel, primaryChannelLink} from '@site/lib/derive';
|
||||
|
||||
/**
|
||||
* 푸터.
|
||||
@@ -14,9 +14,8 @@ import {channelLabel, publicLinks} from '@site/lib/derive';
|
||||
export function SiteFooter() {
|
||||
const payload = useSite();
|
||||
const {place, site} = payload;
|
||||
// 확정된 채널만 — 확정 전 URL 은 동명 업소일 수 있다.
|
||||
// ★ sameAs 와 같은 목록이어야 한다 — 화면에 없는 주소가 구조화 데이터에 있으면 발행이 막힌다.
|
||||
const links = publicLinks(payload);
|
||||
// ★ 확정 채널을 전부 늘어놓지 않는다 — 예약 우선으로 딱 하나만 낸다(seo/jsonld.ts 주석 참고).
|
||||
const link = primaryChannelLink(payload);
|
||||
const address = place.roadAddress ?? place.address;
|
||||
|
||||
return (
|
||||
@@ -58,23 +57,21 @@ export function SiteFooter() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{links.length > 0 && (
|
||||
{link && (
|
||||
<nav aria-label="공식 채널" className="md:col-span-5">
|
||||
<h2 className="label mb-3 !text-current opacity-60">공식 채널</h2>
|
||||
<ul className="flex flex-wrap gap-2">
|
||||
{links.map((link) => (
|
||||
<li key={link.url}>
|
||||
<a
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-1.5 rounded-lg border border-current/25 px-3 py-2 text-[length:var(--fs-xs)] font-medium transition-colors hover:bg-current/10"
|
||||
>
|
||||
<span>{channelLabel(link)}</span>
|
||||
<ExternalLink className="size-3.5" />
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
<li>
|
||||
<a
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-1.5 rounded-lg border border-current/25 px-3 py-2 text-[length:var(--fs-xs)] font-medium transition-colors hover:bg-current/10"
|
||||
>
|
||||
<span>{channelLabel(link)}</span>
|
||||
<ExternalLink className="size-3.5" />
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
)}
|
||||
|
||||
@@ -36,7 +36,17 @@ export function WeatherSection() {
|
||||
const mood = weatherMood(weather?.condition ?? '');
|
||||
const band = weatherBand(weather?.temperature ?? 0);
|
||||
const notes = payload.local.weather;
|
||||
const skyKey = weather?.condition === '구름많음' ? '구름많음' : mood;
|
||||
const {condition} = weather ?? {};
|
||||
const skyKey =
|
||||
condition === '구름많음' ||
|
||||
condition === '안개' ||
|
||||
condition === '소나기' ||
|
||||
condition === '뇌우' ||
|
||||
condition === '이슬비' ||
|
||||
condition === '강한비' ||
|
||||
condition === '어는비'
|
||||
? condition
|
||||
: mood;
|
||||
// 조건별 문장이 우선. 없으면 예전 한 칸(note)으로 떨어진다 — 옛 payload 도 깨지지 않는다.
|
||||
const line = useWeatherNote(notes?.noteSets?.[skyKey], notes?.notes?.[mood] ?? weather?.note);
|
||||
/*
|
||||
|
||||
@@ -223,10 +223,10 @@ describe('예약 버튼은 예약 화면으로 바로 간다', () => {
|
||||
],
|
||||
};
|
||||
|
||||
it('네이버 예약이 플레이스보다 먼저 나온다 — 플레이스는 한 번 더 눌러야 한다', () => {
|
||||
it('네이버 예약이 있으면 네이버 플레이스는 예약 목록에서 빠진다 — 같은 예약이 두 번 뜨지 않는다', () => {
|
||||
const links = stayBookingView(withBooking)!.links;
|
||||
expect(links[0].channel).toBe(LinkChannel.NAVER_BOOKING);
|
||||
expect(links.map((l) => l.channel)).toContain(LinkChannel.NAVER_PLACE);
|
||||
expect(links.map((l) => l.channel)).not.toContain(LinkChannel.NAVER_PLACE);
|
||||
});
|
||||
|
||||
it('버튼 문구가 "네이버 예약에서 예약" 이 되지 않는다', () => {
|
||||
|
||||
@@ -19,6 +19,17 @@ it('uses the first sky and temperature lines for deterministic HTML', () => {
|
||||
expect(render(weather)).toBe(render(weather));
|
||||
});
|
||||
|
||||
it('uses condition-specific notes for fog, showers and thunderstorms', () => {
|
||||
const weather = {temperature: 20, observedAt: '2026-09-15T12:00', condition: '소나기', noteSets: {'소나기': ['소나기 첫 줄']}, tempNoteSets: {'선선': ['선선 첫 줄']}};
|
||||
expect(render(weather)).toContain('소나기 첫 줄');
|
||||
});
|
||||
|
||||
it('uses condition-specific notes for the rain subtypes', () => {
|
||||
const weather = {temperature: 5, observedAt: '2026-09-15T12:00', condition: '어는비', noteSets: {'어는비': ['어는비 첫 줄'], '비': ['일반 비 첫 줄']}, tempNoteSets: {'추움': ['추움 첫 줄']}};
|
||||
expect(render(weather)).toContain('어는비 첫 줄');
|
||||
expect(render(weather)).not.toContain('일반 비 첫 줄');
|
||||
});
|
||||
|
||||
it('preserves legacy single notes', () => {
|
||||
const html = render({temperature: 15, observedAt: '2026-09-15T12:00', condition: '비', notes: {'비': '기존 비 안내'}, tempNotes: {'쌀쌀': '겉옷 안내'}});
|
||||
expect(html).toContain('기존 비 안내');
|
||||
|
||||
@@ -133,10 +133,13 @@ export function publicLinks(payload: SitePayload): ChannelLink[] {
|
||||
|
||||
/**
|
||||
* 확정된 채널만 sameAs 로 나간다 — 확정 전 URL 은 동명 업소일 수 있다.
|
||||
* ★ 목록은 화면(SiteFooter)과 **같은 함수**에서 온다(`publicLinks`) — 갈리면 게이트가 막는다.
|
||||
* ★ 목록은 화면(SiteFooter)과 **같은 함수**에서 온다(`primaryChannelLink`) — 갈리면 게이트가
|
||||
* 막는다. 화면이 "공식 채널" 하나만 보여주는데 sameAs 가 여럿을 주장하면 그것도 어긋남이다
|
||||
* (2026-09-17).
|
||||
*/
|
||||
function sameAs(payload: SitePayload): string[] {
|
||||
return publicLinks(payload).map((link) => link.url);
|
||||
const link = primaryChannelLink(payload);
|
||||
return link ? [link.url] : [];
|
||||
}
|
||||
|
||||
/** 숙박의 체크인·체크아웃은 Schema.org 에 전용 속성이 있다. 있으면 반드시 채운다. */
|
||||
@@ -317,6 +320,53 @@ export const BOOKING_CHANNELS: readonly LinkChannel[] = [
|
||||
LinkChannel.NAVER_PLACE,
|
||||
];
|
||||
|
||||
/** 가게가 아니라 **검색 결과**를 가리키는 주소인지. */
|
||||
function isSearchUrl(url: string): boolean {
|
||||
return /\/p\/search\/|[?&]query=/.test(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 예약을 실제로 받는 확정 채널 전부, **BOOKING_CHANNELS 순서대로**.
|
||||
*
|
||||
* ★ 검색 결과 주소는 뺀다 — 자동 발견이 `map.naver.com/p/search/…` 를 물어오는 경우가 있고
|
||||
* (실측 2026-09-08), 가게를 특정하지 못하는 주소라 예약 창구가 아니다.
|
||||
* ★ 네이버 예약이 있으면 네이버 플레이스는 뺀다 — 둘 다 남으면 화면에 "네이버 예약"과
|
||||
* "네이버 플레이스에서 예약"이 나란히 떠서 같은 예약이 두 번 있는 것처럼 보인다
|
||||
* (2026-09-17). 네이버 플레이스는 직행 예약 채널이 없을 때만 쓰는 대체 창구다.
|
||||
* ★ 화면(BookingSection 등)과 이 함수를 같이 쓴다 — 갈리면 makesOffer/potentialAction 이
|
||||
* 가리키는 곳과 화면 버튼이 어긋난다.
|
||||
*/
|
||||
export function bookingChannelLinks(payload: SitePayload): ChannelLink[] {
|
||||
const order = new Map(BOOKING_CHANNELS.map((channel, index) => [channel, index]));
|
||||
const links = payload.links.filter(
|
||||
(link) => link.confirmed && BOOKING_CHANNELS.includes(link.channel) && !isSearchUrl(link.url),
|
||||
);
|
||||
const hasNaverBooking = links.some((link) => link.channel === LinkChannel.NAVER_BOOKING);
|
||||
return links
|
||||
.filter((link) => !(hasNaverBooking && link.channel === LinkChannel.NAVER_PLACE))
|
||||
.sort((a, b) => (order.get(a.channel) ?? 99) - (order.get(b.channel) ?? 99));
|
||||
}
|
||||
|
||||
/**
|
||||
* 푸터·판권장의 "공식 채널"에 낼 링크 **딱 하나**. `sameAs` 도 이 함수 하나를 같이 쓴다 —
|
||||
* 갈리면 발행 게이트가 막는다(절대규칙 3, 위 `publicLinks` 주석 참고).
|
||||
*
|
||||
* ★ 왜 하나뿐인가 (2026-09-17)
|
||||
* 확정 채널을 전부 늘어놓으면 야놀자·인스타·네이버플레이스·네이버예약이 나란히 서서
|
||||
* 손님이 어디를 눌러야 할지 고르게 만든다. 예약은 이미 본문·상단 버튼이 답했다 —
|
||||
* 맨 아래는 "여기가 이 업장이 맞다"만 확인해 주면 된다.
|
||||
* ★ 우선순위: 공식 사이트 → 예약 채널(`bookingChannelLinks` 순서) → 그래도 없으면
|
||||
* 확정된 링크 중 첫 번째(2026-09-17 수정: 공식 사이트가 있으면 그게 최우선이다 —
|
||||
* 이 자리는 "업장 대표 주소"를 보증하는 자리지 예약 창구가 아니다).
|
||||
*/
|
||||
export function primaryChannelLink(payload: SitePayload): ChannelLink | undefined {
|
||||
return (
|
||||
payload.links.find((link) => link.confirmed && link.channel === LinkChannel.OFFICIAL_SITE) ??
|
||||
bookingChannelLinks(payload)[0] ??
|
||||
publicLinks(payload)[0]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 예약 화면으로 보낼 URL 하나. **가장 앞선 채널**을 고른다(BOOKING_CHANNELS 순서).
|
||||
*
|
||||
@@ -324,11 +374,7 @@ export const BOOKING_CHANNELS: readonly LinkChannel[] = [
|
||||
* 구조화 데이터가 가리키는 곳과 손님이 눌러서 가는 곳이 어긋날 수 없다.
|
||||
*/
|
||||
function bookingChannelUrl(payload: SitePayload): string | undefined {
|
||||
for (const channel of BOOKING_CHANNELS) {
|
||||
const hit = payload.links.find((link) => link.confirmed && link.channel === channel);
|
||||
if (hit) return hit.url;
|
||||
}
|
||||
return undefined;
|
||||
return bookingChannelLinks(payload)[0]?.url;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user