Skip to content

Commit c5b19af

Browse files
authored
Merge pull request #158 from Team-INSERT/refactor/history
refactor : history 페이지
2 parents 8933406 + 7ac78a0 commit c5b19af

File tree

6 files changed

+31
-20
lines changed

6 files changed

+31
-20
lines changed

app/history/[title]/History.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ const History = ({ title }: { title: string }) => {
2222
className={styles.historyBox}
2323
key={String(history.thisVersionCreatedAt)}
2424
>
25-
<div className={styles.hgroup}>
25+
<hgroup className={styles.hgroup}>
2626
<h1 className={styles.historyId}>#{history.index}</h1>
27-
<span className={styles.createdAt}>
27+
<time className={styles.createdAt}>
2828
편집일 ·&nbsp;
2929
{formatDate(history.thisVersionCreatedAt)}
30-
</span>
31-
</div>
30+
</time>
31+
</hgroup>
3232
<span className={styles.author}>작성자 ·&nbsp;{history.nickName}</span>
3333
</Link>
3434
))}

app/history/[title]/detail/[id]/HistoryDetail.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { FC } from "react";
44
import Link from "next/link";
55
import Container from "@/components/Container";
6+
import { VersionDifferent } from "@/enum";
67
import { useSuspenseQuery } from "@tanstack/react-query";
78
import { historyQuery } from "@/services/history/history.query";
89
import * as styles from "./style.css";
@@ -21,33 +22,33 @@ const HistoryDetail: FC<{ id: number; title: string }> = ({ id, title }) => {
2122
docsType={history.docsType}
2223
lastModifiedAt={history.versionDocs.thisVersionCreatedAt}
2324
>
24-
<div className={styles.container}>
25+
<main className={styles.container}>
2526
<Link href={`/user/${history.versionDocs.userId}`} className={styles.author}>
2627
작성자 · {history.versionDocs.nickName}
2728
</Link>
28-
<div className={styles.historyBox}>
29+
<ul className={styles.historyBox}>
2930
{history.diff.map((dif: HistoryType, historyId: number) => {
3031
const operationIcon = (() => {
3132
switch (dif.operation) {
32-
case "INSERT":
33+
case VersionDifferent.INSERT:
3334
return "+";
34-
case "DELETE":
35+
case VersionDifferent.DELETE:
3536
return "-";
36-
case "EQUAL":
37-
return "";
37+
case VersionDifferent.EQUAL:
38+
return;
3839
default:
3940
return dif.operation;
4041
}
4142
})();
4243
return (
43-
<div key={historyId} className={styles.historyContent}>
44-
<div className={styles.historyOperation[dif.operation]}>{operationIcon}</div>
45-
<div className={styles.history[dif.operation]}>{dif.text}</div>
46-
</div>
44+
<li key={historyId} className={styles.historyContent}>
45+
<i className={styles.historyOperation[dif.operation]}>{operationIcon}</i>
46+
<p className={styles.history[dif.operation]}>{dif.text}</p>
47+
</li>
4748
);
4849
})}
49-
</div>
50-
</div>
50+
</ul>
51+
</main>
5152
</Container>
5253
);
5354
};

app/history/[title]/detail/[id]/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ interface PageProps {
1313
}
1414

1515
export const generateMetadata = async ({ params: { title, id } }: PageProps): Promise<Metadata> => {
16+
const decodedTitle = decodeURI(title);
1617
return generateOpenGraph({
17-
title: `역사#${decodeURI(title)}_${id}`,
18-
description: `${decodeURI(title)} 문서의 ${id}번째 역사입니다.`,
18+
title: `역사#${decodedTitle}_${id}`,
19+
description: `${decodedTitle} 문서의 ${id}번째 역사입니다.`,
1920
});
2021
};
2122

app/history/[title]/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ interface PageProps {
1212
}
1313

1414
export const generateMetadata = async ({ params: { title } }: PageProps): Promise<Metadata> => {
15+
const decodedTitle = decodeURI(title);
1516
return generateOpenGraph({
16-
title: `역사#${decodeURI(title)}`,
17-
description: `${decodeURI(title)} 문서의 역사입니다.`,
17+
title: `역사#${decodedTitle}`,
18+
description: `${decodedTitle} 문서의 역사입니다.`,
1819
});
1920
};
2021

enum/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { default as EditorType } from "./editorType.enum";
2+
export { default as VersionDifferent } from "./versionDifferent.enum";

enum/versionDifferent.enum.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
enum VersionDifferent {
2+
INSERT = "INSERT",
3+
DELETE = "DELETE",
4+
EQUAL = "EQUAL",
5+
}
6+
7+
export default VersionDifferent;

0 commit comments

Comments
 (0)