diff --git a/src/features/tech-log/presentation/public/components/public-record-list.tsx b/src/features/tech-log/presentation/public/components/public-record-list.tsx index 520349d..b93782d 100644 --- a/src/features/tech-log/presentation/public/components/public-record-list.tsx +++ b/src/features/tech-log/presentation/public/components/public-record-list.tsx @@ -20,7 +20,11 @@ export function PublicRecordList({ return (
    - {records.map((record) => ( + {records.map((record) => { + const next = [...record.relations].sort( + (left, right) => (left.priority || 0) - (right.priority || 0), + )[0]; + return (
  1. {/* @@ -37,11 +41,25 @@ export function PublicRecordList({ {record.topic} · {record.projectTitle} + {/* + 이 기록에서 무엇으로 이어지는지. 목록이 제목과 요약만 늘어놓으면 이 사이트의 + 기록은 여느 블로그 글과 구분되지 않는다 — 이 기록이 사슬의 한 마디라는 것이 + 목록에서부터 보여야 한다. + + 한 줄만 보인다. 여럿을 붙이면 줄마다 문단이 되어 목록으로서 훑을 수 없다. + */} + {next ? ( + + {next.title} + {next.note?.trim() ? {next.note} : null} + + ) : null}
  2. - ))} + ); + })}
); } diff --git a/src/features/tech-log/presentation/public/pages/search-page.tsx b/src/features/tech-log/presentation/public/pages/search-page.tsx index 8f29d50..d624ef0 100644 --- a/src/features/tech-log/presentation/public/pages/search-page.tsx +++ b/src/features/tech-log/presentation/public/pages/search-page.tsx @@ -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; + + /* + 결과를 한 줄로 늘어놓으면 이 사이트의 검색은 여느 문서 검색과 같아진다. 이 사이트에서 + "가상화" 로 찾는 사람이 정말 원하는 것은 그 말이 들어간 문서 열두 개가 아니라 어디서부터 + 읽을지다. 들어가는 자리(프로젝트)를 먼저 세우고 기록을 그 뒤에 둔다. + */ + 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(); + 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, + title: string, + id: string, + ) => + items.length === 0 ? null : ( +
+

{title}

+
    + {items.map((result) => ( +
  1. + + {labels[result.contentType]} +
    + + + +

    + +

    + {result.topic || result.project ? ( + {[result.topic, result.project].filter(Boolean).join(" · ")} + ) : null} +
    + + +
  2. + ))} +
+
+ ); + return

Search

검색

제목과 요약, 주제, 프로젝트를 함께 검색합니다.

{query ? `“${query}” 검색 결과` : "전체 검색 결과"}

{results.length}개의 검색 결과

- {results.length ?
    {results.map((result) =>
  1. {labels[result.contentType]}
    {result.title}

    {result.summary}

    {result.topic || result.project ? {[result.topic, result.project].filter(Boolean).join(" · ")} : null}
  2. )}
:

일치하는 공개 기록이 없습니다.

} + {results.length === 0 ? ( +

일치하는 공개 기록이 없습니다.

+ ) : ( + <> + {leadTopic ? ( +

+ 여기서부터 + {`“${leadTopic[0]}” 주제에 ${leadTopic[1]}개가 모여 있습니다.`} +

+ ) : null} + {group(entries, "들어가는 자리", "search-entries-title")} + {group(records, "기록", "search-records-title")} + {group(releases, "릴리즈", "search-releases-title")} + + )}
; } diff --git a/src/features/tech-log/presentation/styles/globals.css b/src/features/tech-log/presentation/styles/globals.css index 9854829..2945515 100644 --- a/src/features/tech-log/presentation/styles/globals.css +++ b/src/features/tech-log/presentation/styles/globals.css @@ -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; +} diff --git a/tests/features/tech-log/public-discovery-screens.test.tsx b/tests/features/tech-log/public-discovery-screens.test.tsx index ae0dd84..aebf132 100644 --- a/tests/features/tech-log/public-discovery-screens.test.tsx +++ b/tests/features/tech-log/public-discovery-screens.test.tsx @@ -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(