Merge commit '46171b4f24f2ddc3b9212b9ad6769925bcaceb03' into feature/site-features-and-mockup
# Conflicts: # .env.example # solution/backend/common/enums.py # solution/backend/requirements.txt # solution/backend/services/site_payload.py # solution/backend/services/snapshot.py # solution/backend/services/weather_notes.json # solution/shared/src/types/site-payload.ts # solution/site/src/layouts/editorial/Shell.tsx # solution/site/src/lib/use-live-weather.ts # solution/site/src/pages/HomePage.tsx # solution/site/src/sections/SiteFooter.tsx # solution/site/src/sections/WeatherSection.tsx # solution/site/src/sections/index.ts
This commit is contained in:
commit
b78486b845
74 files changed
+3266
-193
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-100 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 → 화면이 바로 쓰는 모양.
|
||||
@@ -491,23 +491,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,7 +5,8 @@ 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 <= 2) return '구름많음';
|
||||
if (code === 3) return '흐림';
|
||||
|
||||
@@ -2,6 +2,7 @@ import {PlaceCategory} from '@o2o/shared';
|
||||
import {
|
||||
AboutSection,
|
||||
BlogSection,
|
||||
SocialPostsSection,
|
||||
BookingSection,
|
||||
EssentialInfoSection,
|
||||
ExhibitionSection,
|
||||
@@ -85,7 +86,7 @@ export function HomePage() {
|
||||
<HeroSection />
|
||||
|
||||
{payload.theme.sections
|
||||
.filter((section) => section.enabled && section.id !== 'hero')
|
||||
.filter((section) => section.enabled && section.id !== 'hero' && section.id !== 'social')
|
||||
.map((section) => {
|
||||
const Component = SECTION_COMPONENTS[section.id];
|
||||
if (!Component) return null;
|
||||
@@ -127,6 +128,9 @@ export function HomePage() {
|
||||
<ReviewSection />
|
||||
|
||||
<PostcardMakerSection />
|
||||
|
||||
{/* 모든 Shell에서 푸터 바로 위. 에디터 순서를 바꿔도 마지막 위치를 유지한다. */}
|
||||
{isSectionEnabled(payload, 'social') && <div data-editor-id="social"><SocialPostsSection /></div>}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -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 {bookingLabel, publicLinks} from '@site/lib/derive';
|
||||
import {channelLabel, primaryChannelLink} from '@site/lib/derive';
|
||||
|
||||
/**
|
||||
* 푸터.
|
||||
@@ -14,9 +14,8 @@ import {bookingLabel, 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-100">공식 채널</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>{bookingLabel(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>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
|
||||
/** 승인해 함께 발행한 소식의 사본. 플랫폼 인용·임베드·JSON-LD 사실로 취급하지 않는다. */
|
||||
export function SocialPostsSection() {
|
||||
const posts = useSite().socialPosts ?? [];
|
||||
if (!posts.length) return null;
|
||||
return <section id="social-posts" className="mx-auto w-full max-w-5xl px-6 py-12">
|
||||
<h2 className="mb-3 text-2xl font-semibold">함께 발행한 소식</h2>
|
||||
<p className="mb-6 text-sm opacity-70">사장님이 승인해 홈페이지와 Threads에 함께 전한 소식입니다.</p>
|
||||
<div className="grid gap-4 md:grid-cols-3">{posts.map((post) => <article key={post.postId} className="rounded-xl border border-current/15 p-5">
|
||||
<time dateTime={post.postedAt} className="text-sm opacity-70">{new Date(post.postedAt).toLocaleDateString('sv-SE', {timeZone: 'Asia/Seoul'})} (한국시간)</time>
|
||||
<p className="my-4 whitespace-pre-wrap break-words">{post.body}</p>
|
||||
{post.permalink && <a href={post.permalink} target="_blank" rel="noopener noreferrer" className="text-sm underline underline-offset-4">SNS에 올린 글 보기</a>}
|
||||
</article>)}</div>
|
||||
</section>;
|
||||
}
|
||||
@@ -24,4 +24,5 @@ export {MobileTabBar} from './MobileTabBar';
|
||||
// 붙여넣기 아이템 — 데이터가 fact 가 아니라 사장님이 넣은 JSON 에서 온다(theme.sections[].data).
|
||||
export {ITEM_SECTIONS} from './items';
|
||||
export {ReviewSection} from './ReviewSection';
|
||||
export {SocialPostsSection} from './SocialPostsSection';
|
||||
export {PostcardMakerSection} from './items/PostcardMakerSection';
|
||||
@@ -0,0 +1,41 @@
|
||||
import {describe, expect, it} from 'vitest';
|
||||
import {sanitizePayloadForPublish, type SitePayload} from '@o2o/shared';
|
||||
import {MOONLIGHT_STAY_PAYLOAD} from '@site/fixtures/moonlight-stay';
|
||||
import {render} from '@site/entry-server';
|
||||
import {collectJsonLd} from '@site/seo/jsonld';
|
||||
import {homeMeta} from '@site/seo/meta';
|
||||
import {verifyJsonLd} from '@site/seo/verify';
|
||||
|
||||
const post = {postId: 'social-1', provider: 2, body: '새 홈페이지에서 숙소의 확인된 정보를 만나보세요.\n\nhttps://example.com/s/stay', postedAt: '2026-09-13T23:30:00Z', permalink: 'https://www.threads.com/@host/post/abc'};
|
||||
function payload(enabled = true): SitePayload {
|
||||
return {...MOONLIGHT_STAY_PAYLOAD, socialPosts: [post], theme: {...MOONLIGHT_STAY_PAYLOAD.theme,
|
||||
sections: [{id: 'social', name: 'SNS 게시글', enabled, locked: false}, ...MOONLIGHT_STAY_PAYLOAD.theme.sections]}};
|
||||
}
|
||||
|
||||
describe('SNS 소식 정적 발행', () => {
|
||||
it('없는 글이나 꺼진 섹션을 그리지 않는다', () => {
|
||||
expect(render({...payload(), socialPosts: []})).not.toContain('함께 발행한 소식');
|
||||
expect(render(payload(false))).not.toContain('함께 발행한 소식');
|
||||
});
|
||||
it('본문 전문·절대 KST 날짜를 마지막 섹션에 굽고 위젯을 쓰지 않는다', () => {
|
||||
const html = render(sanitizePayloadForPublish(payload()));
|
||||
expect(html).toContain(post.body);
|
||||
expect(html.replace(/<!--.*?-->/g, '')).toContain('2026-09-14 (한국시간)');
|
||||
expect(html).not.toContain('widgets.js');
|
||||
expect(html).not.toContain('platform.twitter.com');
|
||||
expect(html).not.toContain('threads.net/embed');
|
||||
expect(html.indexOf('id="social-posts"')).toBeGreaterThan(html.lastIndexOf('id="location"'));
|
||||
});
|
||||
it('임의의 승인 비밀·위험 링크를 공개 payload에서 뺀다', () => {
|
||||
const dirty = {...post, approval_token_sha: 'secret', permalink: 'javascript:alert(1)'};
|
||||
const clean = sanitizePayloadForPublish({...payload(), socialPosts: [dirty]});
|
||||
expect(JSON.stringify(clean.socialPosts)).not.toContain('secret');
|
||||
expect(clean.socialPosts?.[0].permalink).toBeUndefined();
|
||||
});
|
||||
it('SNS 글을 JSON-LD 주장이나 메타 설명에 넣지 않는다', () => {
|
||||
const input = sanitizePayloadForPublish(payload());
|
||||
const nodes = collectJsonLd(input, homeMeta(input));
|
||||
expect(JSON.stringify(nodes)).not.toContain(post.body);
|
||||
expect(verifyJsonLd(render(input), nodes)).toEqual(verifyJsonLd(render({...input, socialPosts: []}), collectJsonLd({...input, socialPosts: []}, homeMeta(input))));
|
||||
});
|
||||
});
|
||||
@@ -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