Merge branch 'feature/social-post'
This commit is contained in:
commit
46171b4f24
55 files changed
+2872
-7
No files matched your search
@@ -718,6 +718,7 @@ function prerenderSite(
|
||||
const MIN_UNIQUE_TEXT = 8;
|
||||
|
||||
function countUniqueContent(payload: SitePayload): number {
|
||||
// socialPosts는 우리 출력이다. 세면 고유 콘텐츠 0건인 사이트가 자기 소개글로 게이트를 우회한다.
|
||||
const long = (value: unknown) => String(value ?? '').trim().length >= MIN_UNIQUE_TEXT;
|
||||
let count = 0;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {PlaceCategory} from '@o2o/shared';
|
||||
import {
|
||||
AboutSection,
|
||||
SocialPostsSection,
|
||||
BookingSection,
|
||||
EssentialInfoSection,
|
||||
ExhibitionSection,
|
||||
@@ -97,7 +98,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;
|
||||
@@ -132,6 +133,8 @@ export function HomePage() {
|
||||
없는 페이지는 이 업종 질의의 대부분("어떻게 예약해요")에 답을 못 한다.
|
||||
끈 것을 되살리지는 않는다 — 그건 사장님 결정이다. */}
|
||||
{isLodging && !hasSection(payload, 'booking') && <StayBookingSection />}
|
||||
{/* 모든 Shell에서 푸터 바로 위. 에디터 순서를 바꿔도 마지막 위치를 유지한다. */}
|
||||
{isSectionEnabled(payload, 'social') && <div data-editor-id="social"><SocialPostsSection /></div>}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -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>;
|
||||
}
|
||||
@@ -21,4 +21,6 @@ export {SiteFooter} from './SiteFooter';
|
||||
export {MobileTabBar} from './MobileTabBar';
|
||||
// 붙여넣기 아이템 — 데이터가 fact 가 아니라 사장님이 넣은 JSON 에서 온다(theme.sections[].data).
|
||||
export {ITEM_SECTIONS} from './items';
|
||||
|
||||
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))));
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user