[fix] solution/site: 사이트맵 lastmod 를 파일 mtime 에서 뗀다 — 페이지의 dateModified 를 그대로 쓴다

lastmod 를 구운 index.html 의 mtime 에서 읽었다. 렌더러를 배포하면 번들 해시가 바뀌어
내용이 같은 사이트까지 전부 다시 구워지고, mtime 은 그때마다 오늘이 된다 — 사이트맵이
"전 사이트가 오늘 갱신됨" 을 통보한다.

구글은 lastmod 를 페이지의 실제 수정과 대조해 맞을 때만 쓰고 어긋나면 필드를 아예 무시한다
(Search Central: "the date and time of the last significant update" · "consistently and
verifiably accurate"). 지금 뭘 깨뜨리는 게 아니라, 사장님이 진짜로 내용을 고쳐 재발행한
날의 신호를 미리 죽여 두는 종류다. 사이트가 100개를 넘기면 되돌리는 데 시간이 걸린다.

- seo/directory.ts: readBakedTitle · readBakedLastmod 추가. lastmod 는 head 가 선언한
  dateModified(= payload.site.updatedAt) 그 값이다 — 구글이 대조하는 값과 같아 어긋날 수 없다
- scripts/prerender.ts: 사이트맵 항목에서 mtime 제거, 파일 한 번 읽어 제목·lastmod 동시 추출.
  mtime 은 dateModified 메타가 없던 산출물에만 남는 폴백이다
- seo/directory.test.ts: head.ts 태그와 파서의 커플링 고정 — 모양이 바뀌면 파서가 조용히
  undefined 를 내고 mtime 으로 되돌아간다(빌드도 화면도 멀쩡한 회귀)
- docs/DEVLOG.md

tsc·eslint 통과, vitest 22 passed (신규 5건)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018xTWrJ6Mrr6HhEN6hZEER4
This commit is contained in:
minaChoiandClaude Opus 5 committed 2026-09-07 11:39:08 +09:00
1 parent 533de126fb
commit 09b0538c9c
4 files changed
+122 -18

No files matched your search

+17 -18
View File
@@ -22,6 +22,8 @@ import {render} from '@/entry-server';
import {
collectJsonLd,
homeMeta,
readBakedLastmod,
readBakedTitle,
renderHead,
renderLlmsTxt,
renderRootLlmsTxt,
@@ -518,18 +520,21 @@ function writeRootMachineFiles(outRoot: string, origin: string) {
.map((entry) => ({slug: entry.name, file: join(sitesDir, entry.name, 'index.html')}))
// index.html 이 없으면 발행이 끝나지 않은(또는 실패한) 디렉토리다. 사이트맵에 넣지 않는다.
.filter((entry) => existsSync(entry.file))
.map((entry) => ({
// ★ 끝 슬래시를 붙이지 않는다. 페이지의 canonical 은 `/s/<slug>` 다(shared/lib/slug.ts
// publishUrl). 사이트맵이 `/s/<slug>/` 로 어긋나 있던 동안 서치콘솔은 제출한 URL 을
// 전부 "대체 페이지(적절한 표준 태그가 있음)" 로 분류했다 — 색인은 되는데 제출분은
// 0건으로 보이는, 눈으로 원인을 못 찾는 종류다.
loc: joinUrl(origin, SITE_DIR, entry.slug),
// 제목은 구운 HTML 에서 읽는다. payload 에서 가져오면 이번 실행분만 이름이 있고
// 나머지는 슬러그로 떨어진다 — 발행은 바뀐 사이트 하나만 굽기 때문이다.
title: readTitle(entry.file) || entry.slug,
// 페이지는 그 사이트를 구울 때마다 다시 쓰인다 — 파일 mtime 이 곧 마지막 발행 시각이다.
lastmod: statSync(entry.file).mtime.toISOString(),
}))
.map((entry) => {
// 제목과 lastmod 가 같은 HTML 에서 나온다 — 파일은 한 번만 읽는다.
const html = readFileSync(entry.file, 'utf-8');
return {
// ★ 끝 슬래시를 붙이지 않는다. 페이지의 canonical 은 `/s/<slug>` 다(shared/lib/slug.ts
// publishUrl). 사이트맵이 `/s/<slug>/` 로 어긋나 있던 동안 서치콘솔은 제출한 URL 을
// 전부 "대체 페이지(적절한 표준 태그가 있음)" 로 분류했다 — 색인은 되는데 제출분은
// 0건으로 보이는, 눈으로 원인을 못 찾는 종류다.
loc: joinUrl(origin, SITE_DIR, entry.slug),
title: readBakedTitle(html) || entry.slug,
// ★ mtime 으로 떨어지는 건 dateModified 메타가 없던 시절의 산출물뿐이다.
// 그 사이트를 한 번 다시 구우면 제 값이 들어온다(readBakedLastmod 주석 참조).
lastmod: readBakedLastmod(html) ?? statSync(entry.file).mtime.toISOString(),
};
})
.sort((a, b) => a.loc.localeCompare(b.loc));
// ★ `/s/` 목록 페이지. 크롤러가 발행본에 닿는 두 번째 경로다 —
@@ -549,12 +554,6 @@ function writeRootMachineFiles(outRoot: string, origin: string) {
writeIndexNowKey(outRoot);
}
/** 구운 index.html 에서 <title> 만 꺼낸다. 파서를 붙일 값어치가 없는 한 줄짜리 일이다. */
function readTitle(file: string): string {
const match = /<title>([^<]*)<\/title>/.exec(readFileSync(file, 'utf-8'));
return match ? match[1].trim() : '';
}
/**
* IndexNow 키 파일 — `https://<host>/<key>.txt` 에 키 문자열만 들어 있다.
*