Skip to content

Commit

Permalink
Merge branch 'dev' into feature/project-page
Browse files Browse the repository at this point in the history
  • Loading branch information
shimseohyun committed May 16, 2024
2 parents be090df + c94758c commit 1e3d47e
Show file tree
Hide file tree
Showing 61 changed files with 1,527 additions and 940 deletions.
4 changes: 4 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,

// notion image doamin

images: {
domains: ['prod-files-secure.s3.us-west-2.amazonaws.com'],
},
Expand All @@ -27,6 +30,7 @@ const nextConfig = {
fileLoaderRule.exclude = /\.svg$/i;
return config;
},
staticPageGenerationTimeout: 120, // 타임아웃 시간을 120초로 설정
};

export default nextConfig;
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
"clsx": "^2.1.0",
"framer-motion": "^11.1.7",
"next": "14.1.3",
"notion-client": "^6.16.0",
"notion-to-md": "^3.1.1",
"react": "^18",
"react-dom": "^18.2.0",
"react-icons": "^5.0.1",
"swiper": "^11.1.1"
"react-markdown": "^9.0.1",
"swiper": "^11.1.1",
"unified": "^11.0.4"
},
"devDependencies": {
"@svgr/webpack": "^8.1.0",
Expand Down
Binary file added public/GDSC-logo.gif
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 public/GDSC-logo_out.gif
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 public/images/seminar/default_seminar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
5 changes: 5 additions & 0 deletions src/app/api/member/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const notion = new Client({
auth: process.env.NOTION_SECRET_KEY,
});


async function queryAllMemberData(): Promise<any[]> {
try {
const response = await notion.databases.query({
Expand All @@ -13,10 +14,12 @@ async function queryAllMemberData(): Promise<any[]> {
return response.results;
} catch (error) {
console.error(JSON.stringify(error));

throw error;
}
}


export async function GET(req: NextRequest) {
try {
const data = await queryAllMemberData();
Expand All @@ -28,6 +31,7 @@ export async function GET(req: NextRequest) {
},
});
} catch (error) {

return new Response(
JSON.stringify({ message: `Failed: ${error?.toString()}` }),
{
Expand All @@ -39,3 +43,4 @@ export async function GET(req: NextRequest) {
);
}
}

52 changes: 52 additions & 0 deletions src/app/api/seminar/all/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Client } from '@notionhq/client';
import { NextRequest } from 'next/server';

const notion = new Client({
auth: process.env.NOTION_SECRET_KEY,
});

// seminar 데이터 query select, 오름차순
async function queryAllSeminarData(databaseId: string): Promise<any[]> {
try {
const response = await notion.databases.query({
database_id: databaseId,
sorts: [
{
property: 'Date',
direction: 'ascending'
}
]
});

return response.results;
} catch (error) {
console.error('Error querying Notion database and fetching member data:', JSON.stringify(error));
throw error;
}
}

type Data = {
items?: any[];
message: string;
};

export async function GET(req: NextRequest) {
const databaseId = process.env.NOTION_SEMINAR_DATABASE_ID || '';

try {
const data = await queryAllSeminarData(databaseId);
return new Response(JSON.stringify({ data, message: 'Success' }), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});
} catch (error) {
return new Response(JSON.stringify({ message: `Failed: ${error?.toString()}` }), {
status: 500,
headers: {
'Content-Type': 'application/json',
},
});
}
}
48 changes: 48 additions & 0 deletions src/app/api/seminar/open/info/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { Client } from '@notionhq/client';
import { NotionToMarkdown } from "notion-to-md";
import { NextRequest } from 'next/server';

const notion = new Client({
auth: process.env.NOTION_SECRET_KEY,
});

const n2m = new NotionToMarkdown({ notionClient: notion });

async function getPageMarkdown(pageId: string): Promise<any> {
const mdblocks = await n2m.pageToMarkdown(pageId);
const mdString = n2m.toMarkdownString(mdblocks);
return mdString;
}


// Next.js의 API 라우트 핸들러
export async function GET(req: NextRequest) {
const url = new URL(req.url);
const pageId = url.searchParams.get('pageId');

if (!pageId) {
return new Response(JSON.stringify({ message: 'pageId is required' }), {
status: 400,
headers: {
'Content-Type': 'application/json',
},
});
}

try {
const pageContent = await getPageMarkdown(pageId);
return new Response(JSON.stringify({ data: pageContent, message: 'Success' }), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});
} catch (error) {
return new Response(JSON.stringify({ message: `Failed: ${error?.toString()}` }), {
status: 500,
headers: {
'Content-Type': 'application/json',
},
});
}
}
51 changes: 51 additions & 0 deletions src/app/api/seminar/open/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Client } from '@notionhq/client';
import { NextRequest } from 'next/server';

const notion = new Client({
auth: process.env.NOTION_SECRET_KEY,
});

async function queryOpenSeminarData(databaseId: string): Promise<any[]> {
try {
const response = await notion.databases.query({
database_id: databaseId,
sorts: [
{
property: 'Date',
direction: 'ascending'
}
]
});

return response.results;
} catch (error) {
console.error('Error querying Notion database and fetching seminar data:', JSON.stringify(error));
throw error;
}
}

type Data = {
items?: any[];
message: string;
};

export async function GET(req: NextRequest) {
const databaseId = process.env.NOTION_OPEN_SEMINAR_DATABASE_ID || '';

try {
const data = await queryOpenSeminarData(databaseId);
return new Response(JSON.stringify({ data, message: 'Success' }), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});
} catch (error) {
return new Response(JSON.stringify({ message: `Failed: ${error?.toString()}` }), {
status: 500,
headers: {
'Content-Type': 'application/json',
},
});
}
}
59 changes: 59 additions & 0 deletions src/app/api/seminar/review/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Client } from '@notionhq/client';
import { NextRequest } from 'next/server';

const notion = new Client({
auth: process.env.NOTION_SECRET_KEY,
});

// seminar id와 연결된 리뷰 불러오기
async function queryReviewData(databaseId: string, seminarId: string): Promise<any[]> {
try {
const response = await notion.databases.query({
database_id: databaseId,
filter: {
property: 'Seminar',
relation: {
contains: seminarId
}
}
});

return response.results;
} catch (error) {
console.error('Error querying Notion database by Seminar ID:', error);
throw error;
}
}

export async function GET(req: NextRequest) {
const url = new URL(req.url);
const seminarId = url.searchParams.get('seminarId'); // 쿼리 파라미터에서 세미나 ID 가져오기

if (!seminarId) {
return new Response(JSON.stringify({ message: 'Seminar ID is required' }), {
status: 400,
headers: {
'Content-Type': 'application/json',
},
});
}

const databaseId = process.env.NOTION_REVIEW_DATABASE_ID || ''; // 리뷰 데이터베이스 ID

try {
const reviews = await queryReviewData(databaseId, seminarId);
return new Response(JSON.stringify({ reviews, message: 'Success' }), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});
} catch (error) {
return new Response(JSON.stringify({ message: `Failed: ${error?.toString()}` }), {
status: 500,
headers: {
'Content-Type': 'application/json',
},
});
}
}
70 changes: 70 additions & 0 deletions src/app/api/seminar/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { Client } from '@notionhq/client';
import { NextRequest } from 'next/server';

const notion = new Client({
auth: process.env.NOTION_SECRET_KEY,
});

// seminar 데이터 query select, 오름차순
async function querySeminarData(databaseId: string, tag: string): Promise<any[]> {
try {
const response = await notion.databases.query({
database_id: databaseId,
filter: {
property: 'Tags',
multi_select: {
contains: tag
}
},
sorts: [
{
property: 'Date',
direction: 'ascending'
}
]
});

return response.results;
} catch (error) {
console.error('Error querying Notion database and fetching member data:', JSON.stringify(error));
throw error;
}
}

type Data = {
items?: any[];
message: string;
};

export async function GET(req: NextRequest) {
const url = new URL(req.url);
const tag = url.searchParams.get('Tag'); // 쿼리 파라미터에서 세미나 ID 가져오기

if (!tag) {
return new Response(JSON.stringify({ message: 'Tag is required' }), {
status: 400,
headers: {
'Content-Type': 'application/json',
},
});
}

const databaseId = process.env.NOTION_SEMINAR_DATABASE_ID || '';

try {
const data = await querySeminarData(databaseId, tag);
return new Response(JSON.stringify({ data, message: 'Success' }), {
status: 200,
headers: {
'Content-Type': 'application/json',
},
});
} catch (error) {
return new Response(JSON.stringify({ message: `Failed: ${error?.toString()}` }), {
status: 500,
headers: {
'Content-Type': 'application/json',
},
});
}
}
Loading

0 comments on commit 1e3d47e

Please sign in to comment.