Skip to content
Open
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
3 changes: 3 additions & 0 deletions .eslintrc 2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz
.env

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
Binary file added img/basicPoster.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/w.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions next-env.d 2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

export {};
47 changes: 47 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "www.notion.so",
pathname: "**",
},
{
protocol: "https",
hostname: "s3.us-west-2.amazonaws.com",
pathname: "**",
},
{
protocol: "https",
hostname: "images.unsplash.com",
pathname: "**",
},
{
protocol: "https",
hostname: "w.namu.la",
pathname: "**",
},
{
protocol: "https",
hostname: "i.namu.wiki",
pathname: "**",
},
{
protocol: "https",
hostname: "prod-files-secure.s3.us-west-2.amazonaws.com",
pathname: "**",
},
],
},
format: ["image/png", "images/webp", "image/jpeg"],
reactStrictMode: true,
plugins: {
autoprefixer: {},
},
typescript: {
ignoreBuildErrors: true,
},
};

module.exports = nextConfig;
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "q",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@emotion/css": "^11.11.2",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"axios": "^1.6.1",
"emotion": "^11.0.0",
"hoist-non-react-statics": "^3.3.2",
"next": "^14.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-youtube": "^10.1.0",
"recoil": "^0.7.7",
"sharp": "^0.32.6"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.0.2",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
},
"resolutions": {
"react-countup/countup.js": "2.5.0"
}
}
97 changes: 97 additions & 0 deletions src/api/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import CustomAxios from "@/utils/lib/CustomAxios";

export const getAllList = async () => {
let objectArray: object[] = [];
objectArray.push({
property: "Tag",
select: {
equals: "",
},
});
try {
const { data } = await CustomAxios.post("", {
filter: {
and: objectArray,
},
});
const list = data.results;

return list;
Comment on lines +17 to +19
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

바로 return data.results를 해도 무방할 것 같습니다!

} catch (e) {
console.log(e);
return {};
Comment on lines +21 to +22
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

에러가 발생할 시, return문까지 넘어가면 안될 것 같아요!
이런 경우에선 저는 Sentry를 이용하여 에러 트래킹을 해주고 있고, 그 이후에는 바로 throw를 줍니다.

}
};

export const getFilterList = async (names: string) => {
const ArrayNames = names.split(" ");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

변수명은 PascalCase가 아닌 camelCase가 좋을 것 같습니다!

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

역시 사소한거긴 하지만, 개인적으로 변수명을 지을때는 타입/이름이 아닌, 이름/타입의 구조를 더 선호하긴 합니다.
이 경우에선 ArrayNames가 아닌, nameArray 또는 names가 될 수 있겠네요

let objectArray: object[] = [];
ArrayNames.map((i) => {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

사소한거긴 하지만, i 보단 더 의미있는 이름이 좋을 것 같아요! 지금같은 경우에선 arrayNames을 순회하는거니까
arrayNames.map((name) => {})
가 될 수 있겠네요!

if (i === "영화" || i === "드라마") {
objectArray.push({
property: "Tag",
select: {
equals: i,
},
});
} else {
objectArray.push({
property: "Category",
multi_select: {
contains: i,
},
});
}
});

try {
const { data } = await CustomAxios.post("", {
filter: {
and: objectArray,
},
});
const list = data.results;

return list;
} catch (e) {
console.log(e);
return {};
}
};

export const getSerchList = async (name: string) => {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

getSearchList을 의도하신 것 같습니다!
https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker
이런 익스텐션을 사용하면 자동으로 오타를 잡아주니 사용을 해보시는 것도 좋을 것 같습니다!

try {
const { data } = await CustomAxios.post("", {
filter: {
property: "Name",
title: {
contains: name,
},
},
});
const list = data.results;

return list;
} catch (e) {
console.log(e);
return {};
}
};

export const getDetailData = async (name: string) => {
try {
const { data } = await CustomAxios.post("", {
filter: {
property: "Name",
title: {
equals: name,
},
},
});
const detailData = data.results[0];
return detailData;
} catch (e) {
console.log(e);
return;
}
};
19 changes: 19 additions & 0 deletions src/app/(home)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { getAllList } from "@/api/list";
import Home from "@/components/Home";
import { listProps } from "@/types";
import { legnthRn } from "@/utils/lengthRn";

export default async function HomePage() {
const list: listProps[] = await getAllList();
const rn = legnthRn(list);

return (
<Home
list={list}
coverImgUrl={
list[rn]?.cover?.external?.url ?? list[rn]?.cover?.file?.url ?? ""
}
coverImgTitle={list[rn]?.properties.Name.title[0].text.content}
/>
);
}
25 changes: 25 additions & 0 deletions src/app/detail/[name]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import HomeDetail from "@/components/HomeDetail";
import { Props } from "@/types/common";
import { decodeParams } from "@/utils/decodeParams";
import { Metadata } from "next";
import { getDetailData } from "@/api/list";

export const metadata: Metadata = {
title: "Detail",
};

export const DetailPage = async ({ params: { name } }: Props) => {
const detailData = await getDetailData(decodeParams(name));
return <HomeDetail data={detailData} />;
};

// 베포하면 notion img 유효기간때문에 정적인 데이터를 받아오면 유효기간끝나고 에러뜸
// export async function generateStaticParams() {
// const { data } = await CustomAxios.post("");
// const list: listProps[] = data.results;
// return list.map((i) => ({
// name: i.properties.Name.title[0].text.content,
// }));
// }

export default DetailPage;
Binary file added src/app/favicon.ico
Binary file not shown.
28 changes: 28 additions & 0 deletions src/app/filter/[name]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Home from "@/components/Home";
import { listProps } from "@/types";
import { Props } from "@/types/common";
import { decodeParams } from "@/utils/decodeParams";
import { Metadata } from "next";
import { legnthRn } from "@/utils/lengthRn";
import { getFilterList } from "@/api/list";

export const metadata: Metadata = {
title: "Filter",
};

export const FilterPage = async ({ params: { name } }: Props) => {
const list: listProps[] = await getFilterList(decodeParams(name));
const rn = legnthRn(list);

return (
<Home
list={list}
coverImgUrl={
list[rn]?.cover?.external?.url ?? list[rn]?.cover?.file?.url ?? ""
}
coverImgTitle={list[rn]?.properties.Name.title[0].text.content}
/>
);
};

export default FilterPage;
Loading