Skip to content

Commit

Permalink
fix: 프로젝트 thumbnail 없는 케이스 적용 (#206)
Browse files Browse the repository at this point in the history
  • Loading branch information
saseungmin authored Oct 19, 2024
1 parent 5a50e81 commit 0c33c51
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 40 deletions.
6 changes: 3 additions & 3 deletions apps/web/src/app/projects/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { notFound } from 'next/navigation';

import ProjectPage from '@/components/pages/ProjectPage';
import { getProject, getProjects } from '@/lib/apis/project';
import { DEFAULT_METADATA } from '@/lib/constants/metadata';
import METADATA, { DEFAULT_METADATA } from '@/lib/constants/metadata';

export const dynamicParams = false;

Expand All @@ -20,12 +20,12 @@ export function generateMetadata({ params }: Props): Metadata {
return DEFAULT_METADATA;
}

const images = [{
const images = project.thumbnail ? [{
url: project.thumbnail,
width: 800,
height: 600,
alt: project.name,
}];
}] : METADATA.images;

return {
title: `${project.name} - DND`,
Expand Down
18 changes: 10 additions & 8 deletions apps/web/src/components/organisms/ProjectCards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ function ProjectCards({ projects }: Props) {
flag, id, title, thumbnail, skill: skills, name,
}) => (
<Link key={id} className={styles.projectCardWrapper} href={`/projects/${id}`}>
<Image
src={thumbnail}
alt={name}
width="0"
height="0"
sizes="(max-width: 1204px) 50vw, 33vw"
className={styles.thumbnail}
/>
{thumbnail && (
<Image
src={thumbnail}
alt={name}
width="0"
height="0"
sizes="(max-width: 1204px) 50vw, 33vw"
className={styles.thumbnail}
/>
)}
<div className={styles.contents}>
<div className={styles.flag}>{flag}</div>
<div className={styles.name}>{name}</div>
Expand Down
37 changes: 23 additions & 14 deletions apps/web/src/components/organisms/ProjectsSlider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,41 @@ import Marquee from 'react-fast-marquee';
import Image from 'next/image';
import Link from 'next/link';

import { type Project } from '@dnd-academy/core';

import { getProjects } from '@/lib/apis/project';
import blurDataUrl from '@/lib/data/blurDataUrl';

import styles from './index.module.scss';

type ThumbnailProject = Project & {
thumbnail: string;
};

function ProjectsSlider() {
const projects = getProjects();

return (
<div className={styles.projectsSlider}>
<Marquee pauseOnHover speed={100} className={styles.marquee}>
<div className={styles.projectSliderWrapper}>
{projects.slice(0, 20).map(({ id, thumbnail, title }) => (
<Link key={id} href={`/projects/${id}`} prefetch={false}>
<Image
key={id}
src={thumbnail}
alt={title}
width={271}
height={158}
placeholder="blur"
blurDataURL={blurDataUrl.projectSlider}
className={styles.thumbnail}
/>
</Link>
))}
{[...projects]
.filter((project): project is ThumbnailProject => Boolean(project?.thumbnail))
.slice(0, 20)
.map(({ id, thumbnail, title }) => (
<Link key={id} href={`/projects/${id}`} prefetch={false}>
<Image
key={id}
src={thumbnail}
alt={title}
width={271}
height={158}
placeholder="blur"
blurDataURL={blurDataUrl.projectSlider}
className={styles.thumbnail}
/>
</Link>
))}
</div>
</Marquee>
</div>
Expand Down
25 changes: 13 additions & 12 deletions apps/web/src/components/pages/ProjectPage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Image from 'next/image';

import type { Project } from '@dnd-academy/core';
import { type Project } from '@dnd-academy/core';
import { Badge, Button, SkillTag } from '@dnd-academy/ui';

import DetailNavigation from '@/components/molecules/DetailNavigation';
Expand Down Expand Up @@ -39,20 +39,21 @@ function ProjectPage({ project }: Props) {
/>
<div className={styles.projectPageContents}>
<section className={styles.projectDetail}>
{project?.pdf ? (
{project?.pdf && (
<div className={styles.pdfWrapper}>
<PDFViewer url={project.pdf} />
</div>
) : (
<div className={styles.thumbnailWrapper}>
<Image
fill
src={project.thumbnail}
alt={project.name}
className={styles.thumbnail}
sizes="(max-width: 768px) 100vw, 768px"
/>
</div>
)}
{!project?.pdf && project?.thumbnail && (
<div className={styles.thumbnailWrapper}>
<Image
fill
src={project.thumbnail}
alt={project.name}
className={styles.thumbnail}
sizes="(max-width: 768px) 100vw, 768px"
/>
</div>
)}
<div className={styles.projectIntroduceTitleWrapper}>
<div className={styles.header}>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/lib/assets/data/organizers.json
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,8 @@
"linkedin": "https://www.linkedin.com/in/seungmin95"
},
"career": {
"now": ["비마이프렌즈 프론트엔드 개발자"],
"previous": ["카사코리아 프론트엔드 개발자"]
"now": ["레브잇 프론트엔드 개발자"],
"previous": ["비마이프렌즈 프론트엔드 개발자", "카사코리아 프론트엔드 개발자"]
},
"mbti": "INFJ",
"questions": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/@types/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface Project {
images?: string[];
flag: ProjectFlag;
skill: string[];
thumbnail: string;
thumbnail?: string;
pdf: string | null;
projectLinks: ProjectLinks;
}
Expand Down

0 comments on commit 0c33c51

Please sign in to comment.