feat: 목록과 검색이 사슬을 드러낸다

기록 목록은 제목과 요약만 늘어놓았다. 그러면 이 사이트의 기록은 여느 블로그 글과
구분되지 않는다 — 이 기록이 사슬의 한 마디라는 것이 목록에서부터 보여야 한다. 줄마다
이어지는 기록 하나와 작성자가 그 관계에 남긴 문장을 붙인다. 한 줄만 붙인다: 여럿이면
줄마다 문단이 되어 훑을 수 없다.

검색은 결과를 한 줄로 늘어놓았다. "가상화" 로 찾는 사람이 정말 원하는 것은 그 말이
들어간 문서 열두 개가 아니라 어디서부터 읽을지다. 들어가는 자리(프로젝트)를 기록보다
위에 세우고, 그 말이 어느 주제에 모여 있는지를 한 줄로 말한다. 걸린 말은 제목과 요약
안에서 표시한다 — `HighlightMatch` 는 이미 있었는데 검색 화면이 쓰지 않고 있었다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015c8cBFUaVr7KLVUx6ujz7D
This commit is contained in:
DongHyeonka
2026-09-15 20:23:33 +09:00
co-authored by Claude Opus 5
parent db4450fe00
commit d255089571
4 changed files with 153 additions and 4 deletions
@@ -20,7 +20,11 @@ export function PublicRecordList({
return (
<ol className="public-record-list">
{records.map((record) => (
{records.map((record) => {
const next = [...record.relations].sort(
(left, right) => (left.priority || 0) - (right.priority || 0),
)[0];
return (
<li key={record.path}>
<Link to={record.path}>
{/*
@@ -37,11 +41,25 @@ export function PublicRecordList({
<span className="record-context">
{record.topic} · {record.projectTitle}
</span>
{/*
이 기록에서 무엇으로 이어지는지. 목록이 제목과 요약만 늘어놓으면 이 사이트의
기록은 여느 블로그 글과 구분되지 않는다 — 이 기록이 사슬의 한 마디라는 것이
목록에서부터 보여야 한다.
한 줄만 보인다. 여럿을 붙이면 줄마다 문단이 되어 목록으로서 훑을 수 없다.
*/}
{next ? (
<span className="record-next">
{next.title}
{next.note?.trim() ? <em>{next.note}</em> : null}
</span>
) : null}
</div>
<time dateTime={record.publishedAt}>{record.publishedLabel}</time>
</Link>
</li>
))}
);
})}
</ol>
);
}
@@ -2,6 +2,7 @@ import { Link, useNavigate } from "react-router-dom";
import { DOCUMENT_KIND_LABELS } from "../../shared/document-kind-labels.ts";
import type { SearchablePublicEntity } from "../../../application/ports/public-content-queries.ts";
import { HighlightMatch } from "../../shared/highlight-match.tsx";
import { useRouteInput } from "../../../../../presentation/routes/route-input.tsx";
import { usePublicContent } from "../use-public-content.tsx";
@@ -47,10 +48,75 @@ export function SearchPage() {
if (!view.ready) return view.fallback;
const { results } = view.data;
/*
결과를 한 줄로 늘어놓으면 이 사이트의 검색은 여느 문서 검색과 같아진다. 이 사이트에서
"가상화" 로 찾는 사람이 정말 원하는 것은 그 말이 들어간 문서 열두 개가 아니라 <em>어디서부터
읽을지</em>다. 들어가는 자리(프로젝트)를 먼저 세우고 기록을 그 뒤에 둔다.
*/
const entries = results.filter((result) => result.contentType === "PROJECT");
const records = results.filter(
(result) => result.contentType !== "PROJECT" && result.contentType !== "RELEASE",
);
const releases = results.filter((result) => result.contentType === "RELEASE");
/* 가장 많이 걸린 주제. 그 말이 어느 조사에 모여 있는지를 한 줄로 말한다. */
const topicHits = new Map<string, number>();
for (const record of records) {
if (record.topic) topicHits.set(record.topic, (topicHits.get(record.topic) ?? 0) + 1);
}
const leadTopic = [...topicHits.entries()].sort((left, right) => right[1] - left[1])[0];
const group = (
items: ReadonlyArray<SearchablePublicEntity>,
title: string,
id: string,
) =>
items.length === 0 ? null : (
<section className="search-group" aria-labelledby={id}>
<h2 id={id}>{title}</h2>
<ol className="search-page-results">
{items.map((result) => (
<li key={result.path}>
<Link to={result.path}>
<span>{labels[result.contentType]}</span>
<div>
<strong>
<HighlightMatch text={result.title} query={query} />
</strong>
<p>
<HighlightMatch text={result.summary} query={query} />
</p>
{result.topic || result.project ? (
<small>{[result.topic, result.project].filter(Boolean).join(" · ")}</small>
) : null}
</div>
<span aria-hidden="true">↗</span>
</Link>
</li>
))}
</ol>
</section>
);
return <main id="main-content" className="shell search-page">
<header className="public-page-header"><p className="section-kicker">Search</p><h1>검색</h1><p>제목과 요약, 주제, 프로젝트를 함께 검색합니다.</p></header>
<form key={query} className="search-page-form" action="/search" method="get" onSubmit={submit}><label><span className="visually-hidden">검색어</span><input type="search" name="q" defaultValue={query} placeholder="검색어를 입력하세요" /></label><button type="submit">검색</button></form>
<div className="public-result-heading"><h2>{query ? `“${query}” 검색 결과` : "전체 검색 결과"}</h2><p>{results.length}개의 검색 결과</p></div>
{results.length ? <ol className="search-page-results">{results.map((result) => <li key={result.path}><Link to={result.path}><span>{labels[result.contentType]}</span><div><strong>{result.title}</strong><p>{result.summary}</p>{result.topic || result.project ? <small>{[result.topic, result.project].filter(Boolean).join(" · ")}</small> : null}</div><span aria-hidden="true">↗</span></Link></li>)}</ol> : <p className="public-empty-state">일치하는 공개 기록이 없습니다.</p>}
{results.length === 0 ? (
<p className="public-empty-state">일치하는 공개 기록이 없습니다.</p>
) : (
<>
{leadTopic ? (
<p className="search-lead">
<span>여기서부터</span>
{`“${leadTopic[0]}” 주제에 ${leadTopic[1]}개가 모여 있습니다.`}
</p>
) : null}
{group(entries, "들어가는 자리", "search-entries-title")}
{group(records, "기록", "search-records-title")}
{group(releases, "릴리즈", "search-releases-title")}
</>
)}
</main>;
}
@@ -3860,3 +3860,63 @@ textarea.studio-control { min-height: 118px; resize: vertical; line-height: 1.65
.rail-context-kind {
color: var(--faint) !important;
}
/* 목록에서 다음으로 이어지는 줄 */
.record-next {
display: block;
margin-top: 7px;
color: var(--muted);
font-size: 13px;
line-height: 1.55;
}
.record-next::before {
content: "→ ";
color: var(--line-strong);
}
.record-next em {
color: var(--faint);
font-style: normal;
}
.record-next em::before {
content: " · ";
}
/* 검색 — 무엇이 걸렸는가보다 어디서부터 읽을지 */
.search-lead {
margin: 20px 0 0;
color: var(--ink-soft);
font-size: 16px;
}
.search-lead > span {
margin-right: 11px;
color: var(--faint);
font-size: 12px;
font-weight: 650;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.search-group {
margin-top: 38px;
}
.search-group > h2 {
margin: 0;
padding-bottom: 12px;
border-bottom: 1px solid var(--line-strong);
color: var(--muted);
font-size: 13px;
font-weight: 650;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.search-group .search-page-results {
margin-top: 0;
}
@@ -562,11 +562,16 @@ describe("TechLog search discovery", () => {
screen.getAllByRole("listitem").map((item) =>
within(item).queryByRole("link")?.getAttribute("href"),
),
/*
들어가는 자리(프로젝트)가 먼저다. "JPA" 로 찾는 사람이 정말 원하는 것은 그 말이 들어간
문서 넷이 아니라 어디서부터 읽을지이므로, 조사의 입구를 기록보다 위에 세운다. 묶음 안의
순서는 원천 순서 그대로다.
*/
).toEqual([
"/projects/backend-skeleton",
"/cases/collection-fetch-join-pagination",
"/references/jpa-list-fetch-strategy",
"/questions/collection-fetch-join-with-pagination",
"/projects/backend-skeleton",
]);
await user.click(