Files
tech-log-frontend/src/features/tech-log/presentation/public/components/public-document-header.tsx
T
DongHyeonkaandClaude Opus 5 23efcf095c fix: 주제가 없는 기록이 죽은 링크를 달지 않게 한다
주제 없이 게시된 기록이 있는데, 화면이 그것을 모르고 `/topics/` 로 가는 이름 없는 링크를
만들고 있었다 — 문서 머리말의 breadcrumb 과 탐색의 「주제 없음」 묶음 둘 다. 프로젝트
조각은 처음부터 조건부였는데 주제 쪽만 아니었다.

관계 목록의 제목도 기본값으로 옮긴다. 부르는 쪽마다 적게 했더니 다섯 자리 중 둘만
고쳐졌고, 같은 목록이 화면에 따라 두 이름으로 나왔다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011nAjrqNHGPNngN4aUbcyvJ
2026-09-01 17:46:56 +09:00

79 lines
3.2 KiB
TypeScript

import { Link } from "react-router-dom";
import type { PublicRecord } from "../../../application/ports/public-content-queries.ts";
import type { components } from "../../../contracts/studio/generated.ts";
import { ProseText } from "../../shared/public-render/prose-text.tsx";
import { DOCUMENT_KIND_LABELS } from "../../shared/document-kind-labels.ts";
type TargetKind = components["schemas"]["ResolvedRelation"]["targetKind"];
/**
* 공개 주소의 앞머리로 대상 종류를 되짚는다.
*
* <p>목록으로 적는다. 이 자리가 삼항 사슬이던 동안 `/concepts/` 가 어디에도 없어서 개념 문서로
* 가는 관계가 전부 `PROJECT` 로 떨어졌고, 종류 이름이 화면에 「프로젝트」로 나왔다. 종류를
* 더할 때 짝을 빠뜨리는 일이 이 저장소에서만 다섯 번 있었다.
*/
const PATH_PREFIX_KINDS: ReadonlyArray<readonly [string, TargetKind]> = [
["/cases/", "CASE"],
["/references/", "REFERENCE"],
["/questions/", "QUESTION"],
["/concepts/", "CONCEPT"],
];
function targetKindOf(path: string): TargetKind {
const matched = PATH_PREFIX_KINDS.find(([prefix]) => path.startsWith(prefix));
if (matched) return matched[1];
// 결정은 프로젝트 화면 안의 앵커로 산다. 그래서 앞머리가 아니라 조각으로 가른다.
return path.includes("/decisions#") ? "PROJECT_DECISION" : "PROJECT";
}
export function publicRenderModelBase(
record: PublicRecord,
): components["schemas"]["PublicRenderModelBase"] {
return {
kind: record.kind,
slug: record.slug,
title: record.title,
summary: record.summary,
publicPath: record.path,
topic: {
id: `topic-${record.topicSlug}`,
label: record.topic,
/*
주제 화면으로 보낸다. 오래 탐색 필터(`/explore?topic=…`)를 가리켰던 것은 주제 화면이
주제 셋만 열어 두어 나머지가 404 였기 때문이다 — 그 목록이 없어졌으므로 이제 어떤
주제든 자기 화면이 있다.
*/
publicPath: record.topicSlug
? `/topics/${encodeURIComponent(record.topicSlug)}`
: null,
},
project: {
id: `project-${record.projectSlug}`,
label: record.projectTitle,
publicPath: `/projects/${record.projectSlug}`,
},
relations: record.relations.map((relation, index) => ({
id: `public-relation-${index + 1}-${relation.path}`,
targetId: relation.path,
targetKind: targetKindOf(relation.path),
title: relation.title,
/*
렌더 모델의 `reason` 은 작성자가 이 관계에 남긴 문장이다. 공개 조회는 그 문장을 `note`
로 주고, `reason` 자리에는 묶음 이름이 온다 — 두 경로에서 같은 이름이 서로 다른 것을
뜻해서, 작성자가 쓴 문장이 화면에 한 번도 나오지 않은 채로 오래 있었다.
*/
publicPath: relation.path,
reason: relation.note,
/* 계약이 관계마다 주는 요약. 여기서 버리면 목록에 제목만 남는다. */
summary: relation.summary,
order: relation.priority || index + 1,
})),
renderContext: {
generatedAt: record.publishedAt,
dependencyRevision: "public-v1",
},
};
}