Merge branch 'main' into feature/crawler
This commit is contained in:
commit
dd3ad86715
160 files changed
+111240
-202
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import {SourceType} from '@o2o/shared';
|
||||
import {useSite} from '@site/lib/site-context';
|
||||
import {faqList} from '@site/lib/derive';
|
||||
import {Section} from '@site/lib/ui';
|
||||
@@ -18,12 +19,15 @@ export function FaqSection() {
|
||||
|
||||
if (faqs.length === 0) return null;
|
||||
|
||||
// ★ 문의 안내(TEMPLATE)가 섞이면 "모두 사업자가 확인한 내용" 이 거짓이 된다 — 그땐 설명을 달지 않는다.
|
||||
const hasInquiry = faqs.some((faq) => faq.sourceType === SourceType.TEMPLATE);
|
||||
|
||||
return (
|
||||
<Section
|
||||
id="faq"
|
||||
tone="alt"
|
||||
title="자주 묻는 질문"
|
||||
lead="아래 답변은 모두 사업자가 확인한 내용입니다."
|
||||
lead={hasInquiry ? undefined : '아래 답변은 모두 사업자가 확인한 내용입니다.'}
|
||||
>
|
||||
<div className={faqs.length > 4 ? 'grid gap-3 lg:grid-cols-2 lg:gap-4' : 'space-y-3'}>
|
||||
{faqs.map((faq, index) => (
|
||||
|
||||
@@ -145,6 +145,13 @@ export function renderHead({payload, meta, scriptSrc, cssHrefs = []}: HeadOption
|
||||
' <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />',
|
||||
` <title>${escapeHtml(meta.title)}</title>`,
|
||||
tag('meta', {name: 'description', content: meta.description}),
|
||||
/*
|
||||
* SiteOntology 키워드. 구글은 이 태그를 순위에 쓰지 않는다 — 비용이 없어 싣는 자리이고,
|
||||
* 순위에 닿는 자리는 위의 title 이다(meta.ts homeTitle).
|
||||
* ★ 조건부로 넣는다. tag() 는 빈 **속성**만 빼고 태그는 만든다 — 그대로 두면 키워드가 없는
|
||||
* 모든 사이트에 `<meta name="keywords" />` 빈 태그가 박힌다(meta.test.ts 가 잡았다).
|
||||
*/
|
||||
...(meta.keywords ? [tag('meta', {name: 'keywords', content: meta.keywords})] : []),
|
||||
tag('link', {rel: 'canonical', href: meta.canonical}),
|
||||
// 색인을 막을 이유가 없다 — 이 사이트는 색인되라고 존재한다.
|
||||
tag('meta', {
|
||||
|
||||
@@ -6,8 +6,8 @@ import {
|
||||
factValue,
|
||||
joinUrl,
|
||||
sanitizeUnits,
|
||||
selectAnsweredFaqs,
|
||||
selectPublishable,
|
||||
selectPublishableFaqs,
|
||||
type ChannelLink,
|
||||
type FactEntry,
|
||||
type SitePayload,
|
||||
@@ -370,9 +370,10 @@ function priceRange(payload: SitePayload): string | undefined {
|
||||
* FAQPage — AEO 에서 가장 크게 먹히는 마크업.
|
||||
* "체크인 몇 시예요?" 같은 질문에 이 홈페이지가 답으로 잡히는 자리다.
|
||||
* 확인된 FAQ 가 하나도 없으면 아예 내보내지 않는다(빈 FAQPage 는 감점).
|
||||
* ★ 문의 안내(TEMPLATE)는 싣지 않는다 — 답이 없는 문답이다(shared selectAnsweredFaqs).
|
||||
*/
|
||||
export function faqJsonLd(payload: SitePayload): Json | null {
|
||||
const faqs = selectPublishableFaqs(payload.faqs);
|
||||
const faqs = selectAnsweredFaqs(payload.faqs);
|
||||
if (faqs.length === 0) return null;
|
||||
|
||||
return {
|
||||
|
||||
@@ -3,8 +3,8 @@ import {
|
||||
factText,
|
||||
joinUrl,
|
||||
sanitizeUnits,
|
||||
selectAnsweredFaqs,
|
||||
selectPublishable,
|
||||
selectPublishableFaqs,
|
||||
type SitePayload,
|
||||
} from '@o2o/shared';
|
||||
import {BOOKING_CHANNELS, SCHEMA_TYPE, UNIT_SPEC, unitBaseRate} from './jsonld';
|
||||
@@ -88,7 +88,8 @@ export function renderLlmsTxt(payload: SitePayload): string {
|
||||
}
|
||||
|
||||
// ── FAQ — LLM 이 가장 잘 인용하는 부분 ─────────────────
|
||||
const faqs = selectPublishableFaqs(payload.faqs);
|
||||
// ★ 문의 안내(TEMPLATE)는 뺀다. 규칙 3("모르는 것은 정보 없음") 과 달리 질문 자체가 우리가 붙인 것이다.
|
||||
const faqs = selectAnsweredFaqs(payload.faqs);
|
||||
if (faqs.length > 0) {
|
||||
lines.push('## 자주 묻는 질문');
|
||||
lines.push('');
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* SiteOntology 키워드 → 제목 · 메타 키워드.
|
||||
*
|
||||
* ★ 백엔드(services/seo_keywords)가 이미 이 가게 자료로 거른 값만 payload.seo 로 온다.
|
||||
* 여기서 지키는 것은 **자리**다 — 키워드가 없거나 제목이 너무 짧아지면 예전 제목으로 떨어져야 하고,
|
||||
* 키워드가 없는 옛 payload(목업 포함)는 head 가 한 글자도 바뀌면 안 된다.
|
||||
*/
|
||||
import {describe, expect, it} from 'vitest';
|
||||
|
||||
import type {SitePayload} from '@o2o/shared';
|
||||
|
||||
import {MOONLIGHT_STAY_PAYLOAD} from '../fixtures/moonlight-stay';
|
||||
import {renderHead} from './head';
|
||||
import {homeMeta} from './meta';
|
||||
|
||||
function withSeo(seo: SitePayload['seo']): SitePayload {
|
||||
return {...MOONLIGHT_STAY_PAYLOAD, seo};
|
||||
}
|
||||
|
||||
describe('homeMeta — 제목', () => {
|
||||
it('대표 키워드가 있으면 업종어 자리를 대신한다', () => {
|
||||
const meta = homeMeta(withSeo({keywords: [], titleKeyword: '애월 독채펜션'}));
|
||||
expect(meta.title).toBe('달빛스테이 제주 · 애월 독채펜션');
|
||||
});
|
||||
|
||||
it('없으면 예전 제목 그대로다', () => {
|
||||
expect(homeMeta(withSeo({keywords: ['애월 독채펜션']})).title).toBe(homeMeta(MOONLIGHT_STAY_PAYLOAD).title);
|
||||
expect(homeMeta(MOONLIGHT_STAY_PAYLOAD).title).toContain('숙소');
|
||||
});
|
||||
|
||||
it('15자보다 짧아지면 예전 제목으로 떨어진다 — Bing 이 Title too short 로 잡는다', () => {
|
||||
const meta = homeMeta(withSeo({keywords: [], titleKeyword: '독채'}));
|
||||
expect(meta.title).toBe(homeMeta(MOONLIGHT_STAY_PAYLOAD).title);
|
||||
});
|
||||
});
|
||||
|
||||
describe('renderHead — keywords 메타', () => {
|
||||
it('키워드를 쉼표로 이어 싣고 이스케이프한다', () => {
|
||||
const payload = withSeo({keywords: ['애월 독채펜션', '고내리 "바다" 숙소']});
|
||||
const head = renderHead({payload, meta: homeMeta(payload)});
|
||||
expect(head).toContain('<meta name="keywords" content="애월 독채펜션, 고내리 "바다" 숙소" />');
|
||||
});
|
||||
|
||||
it('키워드가 없으면 태그를 만들지 않는다', () => {
|
||||
const head = renderHead({payload: MOONLIGHT_STAY_PAYLOAD, meta: homeMeta(MOONLIGHT_STAY_PAYLOAD)});
|
||||
expect(head).not.toContain('name="keywords"');
|
||||
const empty = withSeo({keywords: []});
|
||||
expect(renderHead({payload: empty, meta: homeMeta(empty)})).not.toContain('name="keywords"');
|
||||
});
|
||||
});
|
||||
@@ -19,6 +19,8 @@ export interface PageMeta {
|
||||
canonical: string;
|
||||
ogImage?: string;
|
||||
ogImageAlt?: string;
|
||||
/** `<meta name="keywords">`. SiteOntology 키워드가 없으면 비어 태그를 만들지 않는다. */
|
||||
keywords?: string;
|
||||
}
|
||||
|
||||
function url(payload: SitePayload, ...parts: string[]): string {
|
||||
@@ -128,15 +130,28 @@ const CATEGORY_WORD: Record<PlaceCategory, string> = {
|
||||
[PlaceCategory.CLINIC]: '의원',
|
||||
};
|
||||
|
||||
/** Bing 웹마스터도구가 이보다 짧은 제목을 Error(Title too short)로 잡는다. */
|
||||
const MIN_TITLE_LENGTH = 15;
|
||||
|
||||
/**
|
||||
* `<상호> · <지역> <업종>`.
|
||||
*
|
||||
* ★ `<상호> · <시군구>` 였다. "스테이,머뭄 · 군산시" 는 12자인데 Bing 웹마스터도구가
|
||||
* **15자 미만을 Error(Title too short)** 로 잡는다. 광역시도와 업종어를 같이 실어
|
||||
* 길이도 채우고 "군산 숙소" 같은 질의에도 걸리게 한다.
|
||||
* ★ SiteOntology 대표 키워드가 오면 `<상호> · <키워드>` 다 (2026-09-14).
|
||||
* "숙소" 는 업종별 고정어라 "군산 숙소" 질의에만 걸린다. 키워드는 백엔드가 이 가게 자료로 거르고
|
||||
* 시·군 이름을 품은 것만 보내므로(services/seo_keywords) 지역 신호는 그대로 남는다.
|
||||
* 붙였더니 15자보다 짧으면 예전 제목으로 떨어진다.
|
||||
*/
|
||||
function homeTitle(payload: SitePayload): string {
|
||||
const {place} = payload;
|
||||
const keyword = payload.seo?.titleKeyword?.trim();
|
||||
if (keyword) {
|
||||
const title = `${place.name} · ${keyword}`;
|
||||
if (title.length >= MIN_TITLE_LENGTH) return title;
|
||||
}
|
||||
|
||||
const region = place.addressRegion && place.addressRegion !== localName(payload)
|
||||
? place.addressRegion
|
||||
: undefined;
|
||||
@@ -144,6 +159,12 @@ function homeTitle(payload: SitePayload): string {
|
||||
return [place.name, where].filter(Boolean).join(' · ');
|
||||
}
|
||||
|
||||
/** `<meta name="keywords">` 값. 키워드가 없으면 undefined — head 가 태그를 만들지 않는다. */
|
||||
export function metaKeywords(payload: SitePayload): string | undefined {
|
||||
const words = (payload.seo?.keywords ?? []).map((word) => word.trim()).filter(Boolean);
|
||||
return words.length > 0 ? words.join(', ') : undefined;
|
||||
}
|
||||
|
||||
export function homeMeta(payload: SitePayload): PageMeta {
|
||||
const image = primaryImage(payload);
|
||||
return {
|
||||
@@ -152,5 +173,6 @@ export function homeMeta(payload: SitePayload): PageMeta {
|
||||
canonical: url(payload),
|
||||
ogImage: image?.url,
|
||||
ogImageAlt: image?.alt,
|
||||
keywords: metaKeywords(payload),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user