feat(share): 링크 공유 미리보기 이미지와 파비콘
카카오톡·슬랙·iMessage 에 사이트 주소를 붙이면 회색 링크 아이콘만 나왔다.
webforai.kr 은 og:image 와 파비콘이 없었고, 서포터즈 사이트는 robots.txt 가
미리보기 봇까지 막았으며 파비콘이 Astro 기본 로고였다.
- scripts/make_share_assets.py: 1200x630 공유 이미지(JPEG)와 파비콘 세트 생성.
서포터즈는 해외 환자용 영어 판(병원 공식 영문 표기 shareNameEn), 파비콘은 영문 첫 글자.
- 워커 build 단계에서 자동 생성. briefs/<clinic>/clinic.json 에 shareNameEn 과 출처.
- Base.astro: og:image 기본값 /og.jpg, 크기·twitter:card·아이콘 링크.
- robots.txt(샘플): 미리보기 봇만 허용. 검색·AI 크롤러 차단과 noindex 는 유지.
- vite.config.ts: discovery 빌드에만 og:image·아이콘 태그. public/ 은 infinith-demo 와
공용이라 파일명에 discovery- 접두어.
- Astro 기본 favicon.svg 삭제는 직전 커밋(f2fe99b)에 섞여 들어갔다.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
f2fe99b81d
commit
f6aae1c396
16 files changed
+272
-12
No files matched your search
@@ -1,5 +1,6 @@
|
||||
---
|
||||
import '../styles/global.css';
|
||||
import { existsSync } from 'node:fs';
|
||||
import { SITE_NAME, SITE_TAGLINE, INDEXABLE, fact, site as S, surface, reservationUrl, editor, has, v } from '../lib';
|
||||
import { UI, switchHref } from '../lib/i18n';
|
||||
import EN from '../data/factSheetEn.json';
|
||||
@@ -16,7 +17,9 @@ interface Props {
|
||||
lang?: 'ko' | 'en';
|
||||
alternates?: { lang: string; href: string }[];
|
||||
}
|
||||
const { title, description, jsonLd, ogImage = S.buildingImage?.src || '/favicon.svg', type = 'website', noindex = false, lang = 'ko', alternates = [] } = Astro.props;
|
||||
// 공유 미리보기 기본 이미지: 워커 build 단계가 만드는 public/og.jpg(1200x630, scripts/make_share_assets.py). 없으면 건물 사진.
|
||||
const shareCard = existsSync('public/og.jpg');
|
||||
const { title, description, jsonLd, ogImage = shareCard ? '/og.jpg' : (S.buildingImage?.src || '/favicon-512.png'), type = 'website', noindex = false, lang = 'ko', alternates = [] } = Astro.props;
|
||||
const site = Astro.site?.toString().replace(/\/$/, '') ?? '';
|
||||
const cleanPath = Astro.url.pathname.replace(/\/index\.html$/, '/').replace(/\.html$/, '');
|
||||
const canonical = (new URL(cleanPath, Astro.site).toString().replace(/\/$/, '') || site);
|
||||
@@ -54,6 +57,13 @@ const ld = jsonLd ? JSON.stringify({ '@context': 'https://schema.org', ...(Array
|
||||
<meta property="og:description" content={description} />
|
||||
<meta property="og:url" content={canonical} />
|
||||
<meta property="og:image" content={new URL(ogImage, Astro.site).toString()} />
|
||||
{ogImage === '/og.jpg' && <meta property="og:image:width" content="1200" />}
|
||||
{ogImage === '/og.jpg' && <meta property="og:image:height" content="630" />}
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<link rel="icon" href="/favicon.ico" sizes="48x48" />
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32.png" />
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="/favicon-192.png" />
|
||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||
<meta property="og:locale" content={lang === 'en' ? 'en_US' : 'ko_KR'} />
|
||||
{alternates.map((a) => <link rel="alternate" hreflang={a.lang} href={`${site}${a.href}`} />)}
|
||||
<link rel="stylesheet" as="style" crossorigin href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css" />
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import type { APIRoute } from 'astro';
|
||||
// 샘플: 전면 차단. 프로덕션(PUBLIC_INDEXABLE=true): 전면 허용 + AI 크롤러 명시 허용.
|
||||
// 샘플: 검색·AI 크롤러 전면 차단. 프로덕션(PUBLIC_INDEXABLE=true): 전면 허용 + AI 크롤러 명시 허용.
|
||||
// 링크 미리보기 봇은 샘플에서도 허용한다. 막으면 카카오톡·슬랙·iMessage 에 주소를 붙였을 때 제목·이미지가 안 나온다.
|
||||
// 이 봇들은 붙여 넣은 주소 한 장만 읽고 색인하지 않는다. noindex 메타·X-Robots-Tag 는 그대로다.
|
||||
const PREVIEW_BOTS = ['kakaotalk-scrap', 'facebookexternalhit', 'Facebot', 'Twitterbot', 'Slackbot', 'Slackbot-LinkExpanding', 'Discordbot', 'TelegramBot', 'WhatsApp', 'LinkedInBot'];
|
||||
const AI_BOTS = ['GPTBot', 'OAI-SearchBot', 'ChatGPT-User', 'PerplexityBot', 'ClaudeBot', 'Claude-SearchBot', 'Google-Extended', 'Applebot-Extended', 'Bingbot', 'Yeti', 'Googlebot'];
|
||||
export const GET: APIRoute = ({ site }) => {
|
||||
const indexable = import.meta.env.PUBLIC_INDEXABLE === 'true';
|
||||
const body = indexable
|
||||
? [...AI_BOTS.map((b) => `User-agent: ${b}\nAllow: /`), 'User-agent: *\nAllow: /', `Sitemap: ${site}sitemap.xml`].join('\n\n') + '\n'
|
||||
: `# 샘플 사이트. 색인 금지.\nUser-agent: *\nDisallow: /\n`;
|
||||
: [`# 샘플 사이트. 색인 금지. 링크 미리보기만 허용.`, ...PREVIEW_BOTS.map((b) => `User-agent: ${b}\nAllow: /`), 'User-agent: *\nDisallow: /'].join('\n\n') + '\n';
|
||||
return new Response(body, { headers: { 'Content-Type': 'text/plain; charset=utf-8' } });
|
||||
};
|
||||
Reference in new issue
Block a user