diff --git a/scripts/generate-nginx-config.ts b/scripts/generate-nginx-config.ts index 5b0ef16..308ea6b 100644 --- a/scripts/generate-nginx-config.ts +++ b/scripts/generate-nginx-config.ts @@ -200,6 +200,14 @@ ${studioLocations} add_header Cache-Control "${assetCache}" always; } + # 크롤러가 처음 찾는 파일이다. 여기 없으면 SPA 폴백이 index.html 을 주고, + # 크롤러는 그것을 규칙으로 읽을 수 없어 결국 아무 규칙도 없는 것과 같아진다. + location = ${basePath}/robots.txt { + alias /usr/share/nginx/html/robots.txt; + default_type text/plain; + add_header Cache-Control "${indexCache}" always; + } + location = ${basePath}/media/ { return 404; } diff --git a/src/features/tech-log/adapters/http/public-content-mapping.ts b/src/features/tech-log/adapters/http/public-content-mapping.ts index e88a078..35d7dd0 100644 --- a/src/features/tech-log/adapters/http/public-content-mapping.ts +++ b/src/features/tech-log/adapters/http/public-content-mapping.ts @@ -95,13 +95,27 @@ export function markdownSections(body: string | null | undefined): RecordSection } /** Markdown that is really a list — the release document's four bodies are. */ +/** + * 릴리스 노트의 한 칸을 항목 목록으로 읽는다. + * + *
예전에는 줄을 쪼개고 `- ` 만 떼어 냈다. 그래서 작성자가 소제목으로 쓴 `## 작성` 이 항목 + * 하나로 섞여 들어갔고, `:::note` 나 `` 같은 블록 문법도 글자 그대로 목록에 + * 나왔다. 그 릴리스 노트의 내용이 하필 "본문의 표·코드·callout·그림이 렌더링됩니다" 였다. + * + *
여기서 다루는 것은 목록이므로 소제목은 버린다 — 소제목까지 살리려면 화면이 절을 나눠야 + * 하는데, 이 칸은 「무엇이 바뀌었나」 아래의 한 목록이다. 백틱은 남겨서 화면이 코드로 그린다. + */ export function markdownLines(body: string | null | undefined): string[] { if (!body) return []; return body .split(/\r?\n/u) .map((line) => line.trim()) .filter((line) => line.length > 0) - .map((line) => line.replace(/^[-*]\s+/u, "")); + // 소제목·수평선·블록 울타리는 항목이 아니다. + .filter((line) => !/^#{1,6}\s/u.test(line)) + .filter((line) => !/^(?::::|---+|\*\*\*+)/u.test(line)) + .map((line) => line.replace(/^[-*]\s+/u, "")) + .map((line) => line.replace(/^\d+\.\s+/u, "")); } function slugOf(title: string, index: number): string { diff --git a/src/features/tech-log/presentation/public/pages/release-page.tsx b/src/features/tech-log/presentation/public/pages/release-page.tsx index f6d45ba..fb3de3c 100644 --- a/src/features/tech-log/presentation/public/pages/release-page.tsx +++ b/src/features/tech-log/presentation/public/pages/release-page.tsx @@ -5,6 +5,7 @@ import { useRouteInput, } from "../../../../../presentation/routes/route-input.tsx"; import { usePublicContent } from "../use-public-content.tsx"; +import { ProseText } from "../../shared/public-render/prose-text.tsx"; export function ReleasePage() { const { params } = useRouteInput<"TECH_LOG_RELEASE">(); @@ -26,7 +27,7 @@ export function ReleasePage() {
Release v{release.version}
{release.summary}
+` 가 되지만 여기서는 검색 결과에 그 문자가 그대로 나간다.
+ */
+ element.content = description
+ .replace(/`/gu, "")
+ .replace(/\s+/gu, " ")
+ .trim()
+ .slice(0, 200);
}
return () => {
diff --git a/tests/component/prose-text.test.tsx b/tests/component/prose-text.test.tsx
index 60c39c5..0d37596 100644
--- a/tests/component/prose-text.test.tsx
+++ b/tests/component/prose-text.test.tsx
@@ -50,3 +50,29 @@ describe("산문 칸", () => {
expect(container.querySelectorAll("p")).toHaveLength(0);
});
});
+
+/**
+ * 릴리스 노트의 각 칸은 Markdown 으로 쓰이는데 목록으로만 읽혀서, 소제목과 블록 문법이 항목에
+ * 섞여 나왔다. 그 노트의 내용이 하필 "본문의 표·코드·callout·그림이 렌더링됩니다" 였다.
+ */
+describe("릴리스 노트 목록 읽기", () => {
+ it("소제목·수평선·블록 울타리를 항목으로 세지 않는다", async () => {
+ const { markdownLines } = await import(
+ "../../src/features/tech-log/adapters/http/public-content-mapping.ts"
+ );
+ expect(
+ markdownLines("## 작성\n\n- 편집 화면의 버튼을 줄였습니다.\n- 채워야 할 칸을 표시합니다.\n\n---\n\n## 본문 문법\n:::note\n- 표를 지원합니다."),
+ ).toEqual([
+ "편집 화면의 버튼을 줄였습니다.",
+ "채워야 할 칸을 표시합니다.",
+ "표를 지원합니다.",
+ ]);
+ });
+
+ it("번호 목록도 항목으로 읽는다", async () => {
+ const { markdownLines } = await import(
+ "../../src/features/tech-log/adapters/http/public-content-mapping.ts"
+ );
+ expect(markdownLines("1. 첫째\n2. 둘째")).toEqual(["첫째", "둘째"]);
+ });
+});