Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor : history 페이지 #158

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions app/history/[title]/History.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ const History = ({ title }: { title: string }) => {
className={styles.historyBox}
key={String(history.thisVersionCreatedAt)}
>
<div className={styles.hgroup}>
<hgroup className={styles.hgroup}>
<h1 className={styles.historyId}>#{history.index}</h1>
<span className={styles.createdAt}>
<time className={styles.createdAt}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰에 달만한 내용은 아니지만, 이런게 있는지 오늘 처음 알았습니다. 신기하네요

Copy link
Member Author

@Ubinquitous Ubinquitous Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰에 달아주셔도 좋습니다!!
저도 이번에 SEO를 향상시키는 방법 중, 시멘틱 태그에 관심이 생겨서 여러가지 태그들을 찾아보았는데,
저희가 흔히 알고 있는 section, article 뿐만 아니라 figure, figcaption, time 등등
여러가지 시멘틱 태그가 있다는 것을 알게 되었습니다!

앞으로도 SEO 향상을 위해서 어떤 부분에서는 실수로 시멘틱 태그를 의도와 맞지 않게 사용하는 한이 있더라도
전체적인 부면을 보면서 시멘틱 태그를 사용하는 습관을 들여야겠다고 생각했습니다!
이번 프로젝트에서는 vanilla extract를 사용 하다보니 태그명이 그대로 눈에 들어와서 시멘틱 태그를 적용하고 나니
확실히 훨씬 각 엘리먼트들이 어떤 정보를 나타내는 지도 더욱 상세히 알 수 있었습니다!!

편집일 ·&nbsp;
{formatDate(history.thisVersionCreatedAt)}
</span>
</div>
</time>
</hgroup>
<span className={styles.author}>작성자 ·&nbsp;{history.nickName}</span>
</Link>
))}
Expand Down
25 changes: 13 additions & 12 deletions app/history/[title]/detail/[id]/HistoryDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { FC } from "react";
import Link from "next/link";
import Container from "@/components/Container";
import { VersionDifferent } from "@/enum";
import { useSuspenseQuery } from "@tanstack/react-query";
import { historyQuery } from "@/services/history/history.query";
import * as styles from "./style.css";
Expand All @@ -21,33 +22,33 @@ const HistoryDetail: FC<{ id: number; title: string }> = ({ id, title }) => {
docsType={history.docsType}
lastModifiedAt={history.versionDocs.thisVersionCreatedAt}
>
<div className={styles.container}>
<main className={styles.container}>
<Link href={`/user/${history.versionDocs.userId}`} className={styles.author}>
작성자 · {history.versionDocs.nickName}
</Link>
<div className={styles.historyBox}>
<ul className={styles.historyBox}>
{history.diff.map((dif: HistoryType, historyId: number) => {
const operationIcon = (() => {
switch (dif.operation) {
case "INSERT":
case VersionDifferent.INSERT:
return "+";
case "DELETE":
case VersionDifferent.DELETE:
return "-";
case "EQUAL":
return "";
case VersionDifferent.EQUAL:
return;
default:
return dif.operation;
}
})();
return (
<div key={historyId} className={styles.historyContent}>
<div className={styles.historyOperation[dif.operation]}>{operationIcon}</div>
<div className={styles.history[dif.operation]}>{dif.text}</div>
</div>
<li key={historyId} className={styles.historyContent}>
<i className={styles.historyOperation[dif.operation]}>{operationIcon}</i>
<p className={styles.history[dif.operation]}>{dif.text}</p>
</li>
);
})}
</div>
</div>
</ul>
</main>
</Container>
);
};
Expand Down
5 changes: 3 additions & 2 deletions app/history/[title]/detail/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ interface PageProps {
}

export const generateMetadata = async ({ params: { title, id } }: PageProps): Promise<Metadata> => {
const decodedTitle = decodeURI(title);
return generateOpenGraph({
title: `역사#${decodeURI(title)}_${id}`,
description: `${decodeURI(title)} 문서의 ${id}번째 역사입니다.`,
title: `역사#${decodedTitle}_${id}`,
description: `${decodedTitle} 문서의 ${id}번째 역사입니다.`,
});
};

Expand Down
5 changes: 3 additions & 2 deletions app/history/[title]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ interface PageProps {
}

export const generateMetadata = async ({ params: { title } }: PageProps): Promise<Metadata> => {
const decodedTitle = decodeURI(title);
return generateOpenGraph({
title: `역사#${decodeURI(title)}`,
description: `${decodeURI(title)} 문서의 역사입니다.`,
title: `역사#${decodedTitle}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어차피 같은 데이터 사용할건데 두번 요청할 필요 없죠. 좋습니다~~

description: `${decodedTitle} 문서의 역사입니다.`,
});
};

Expand Down
1 change: 1 addition & 0 deletions enum/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as EditorType } from "./editorType.enum";
export { default as VersionDifferent } from "./versionDifferent.enum";
7 changes: 7 additions & 0 deletions enum/versionDifferent.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enum VersionDifferent {
INSERT = "INSERT",
DELETE = "DELETE",
EQUAL = "EQUAL",
}

export default VersionDifferent;