-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from hackerspace-ntnu/22-feat-create-individua…
…l-news-article-pages 22 feat create individual news article pages
- Loading branch information
Showing
48 changed files
with
987 additions
and
671 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,17 +9,15 @@ | |
"build": "next build", | ||
"dev": "next dev", | ||
"lint": "next lint", | ||
"format": "prettier --check '**/*.{js,cjs,ts,tsx}'", | ||
"type": "tsc --noEmit", | ||
"start": "next start" | ||
}, | ||
"lint-staged": { | ||
"*.{js,cjs,ts,tsx}": [ | ||
"eslint --fix", | ||
"prettier --write" | ||
"eslint --fix" | ||
] | ||
}, | ||
"dependencies": { | ||
"@radix-ui/react-avatar": "^1.0.4", | ||
"@radix-ui/react-dialog": "^1.0.5", | ||
"@radix-ui/react-dropdown-menu": "^2.0.6", | ||
"@radix-ui/react-separator": "^1.0.3", | ||
|
@@ -30,6 +28,7 @@ | |
"clsx": "^2.1.0", | ||
"country-flag-icons": "^1.5.9", | ||
"cva": "^1.0.0-beta.1", | ||
"husky": "^9.0.10", | ||
"lucide-react": "^0.312.0", | ||
"next": "^14.0.4", | ||
"next-intl": "^3.4.4", | ||
|
@@ -38,9 +37,9 @@ | |
"nuqs": "^1.15.4", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"reading-time": "^1.5.0", | ||
"sharp": "^0.33.2", | ||
"tailwind-merge": "^2.2.0", | ||
"tailwind-scrollbar": "^3.0.5", | ||
"tailwindcss-animate": "^1.0.7", | ||
"zod": "^3.22.4" | ||
}, | ||
"devDependencies": { | ||
|
@@ -53,12 +52,15 @@ | |
"@typescript-eslint/parser": "^6.11.0", | ||
"eslint": "^8.54.0", | ||
"eslint-config-next": "^14.0.4", | ||
"husky": "^8.0.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"lint-staged": "^15.2.0", | ||
"postcss": "^8.4.31", | ||
"prettier": "^3.1.0", | ||
"prettier-plugin-tailwindcss": "^0.5.7", | ||
"tailwind-scrollbar": "^3.0.5", | ||
"tailwindcss": "^3.3.5", | ||
"tailwindcss-animate": "^1.0.7", | ||
"typescript": "^5.1.6" | ||
}, | ||
"packageManager": "[email protected]" | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
{ | ||
"name": "", | ||
"short_name": "", | ||
"icons": [ | ||
{ | ||
"src": "/android-chrome-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "/android-chrome-512x512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
} | ||
], | ||
"theme_color": "#0c0a09", | ||
"background_color": "#0c0a09", | ||
"display": "standalone" | ||
"name": "Hackerspace NTNU", | ||
"short_name": "Hackerspace", | ||
"icons": [ | ||
{ | ||
"src": "/android-chrome-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "/android-chrome-512x512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
} | ||
], | ||
"theme_color": "#0c0a09", | ||
"background_color": "#0c0a09", | ||
"display": "standalone" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { SquarePen } from 'lucide-react'; | ||
import { useTranslations } from 'next-intl'; | ||
import { unstable_setRequestLocale } from 'next-intl/server'; | ||
|
||
import { Link } from '@/lib/navigation'; | ||
|
||
import { Button } from '@/components/ui/Button'; | ||
|
||
type NewsHeaderProps = { | ||
children: React.ReactNode; | ||
params: { locale: string }; | ||
}; | ||
|
||
export default function NewsHeader({ | ||
children, | ||
params: { locale }, | ||
}: NewsHeaderProps) { | ||
unstable_setRequestLocale(locale); | ||
const t = useTranslations('news'); | ||
return ( | ||
<> | ||
<div className='flex items-center justify-between'> | ||
<h1 className='my-4'>{t('title')}</h1> | ||
<Button asChild size='sm'> | ||
<Link href='/news/new'> | ||
<SquarePen className='mr-2 h-4 w-4' /> | ||
{t('newArticle')} | ||
</Link> | ||
</Button> | ||
</div> | ||
{children} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { PaginationCarouselSkeleton } from '@/components/layout/PaginationCarouselSkeleton'; | ||
import { CardGridSkeleton } from '@/components/news/CardGridSkeleton'; | ||
import { ItemGridSkeleton } from '@/components/news/ItemGridSkeleton'; | ||
import { Separator } from '@/components/ui/Separator'; | ||
|
||
export default function NewsSkeleton() { | ||
return ( | ||
<> | ||
<CardGridSkeleton /> | ||
<Separator className='my-6' /> | ||
<ItemGridSkeleton /> | ||
<PaginationCarouselSkeleton className='my-6' /> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { articleMockData as articleData } from '@/mock-data/article'; | ||
import { useTranslations } from 'next-intl'; | ||
import { getTranslations, unstable_setRequestLocale } from 'next-intl/server'; | ||
import { createSearchParamsCache, parseAsInteger } from 'nuqs/parsers'; | ||
import { Suspense } from 'react'; | ||
|
||
import { PaginationCarousel } from '@/components/layout/PaginationCarousel'; | ||
import { CardGrid } from '@/components/news/CardGrid'; | ||
import { ItemGrid } from '@/components/news/ItemGrid'; | ||
import { ItemGridSkeleton } from '@/components/news/ItemGridSkeleton'; | ||
import { Separator } from '@/components/ui/Separator'; | ||
|
||
export async function generateMetadata({ | ||
params: { locale }, | ||
}: { | ||
params: { locale: string }; | ||
}) { | ||
const t = await getTranslations({ locale, namespace: 'layout' }); | ||
|
||
return { | ||
title: t('news'), | ||
}; | ||
} | ||
|
||
export default function News({ | ||
params: { locale }, | ||
searchParams, | ||
}: { | ||
params: { locale: string }; | ||
searchParams: Record<string, string | string[] | undefined>; | ||
}) { | ||
unstable_setRequestLocale(locale); | ||
const t = useTranslations('ui'); | ||
const searchParamsCache = createSearchParamsCache({ | ||
[t('page')]: parseAsInteger.withDefault(1), | ||
}); | ||
|
||
const { [t('page')]: page = 1 } = searchParamsCache.parse(searchParams); | ||
// TODO: Button to create new article should only be visible when logged in | ||
return ( | ||
<> | ||
<CardGrid topArticles={articleData.slice(0, 4)} /> | ||
<Separator className='my-6' /> | ||
<Suspense key={page} fallback={<ItemGridSkeleton />}> | ||
<ItemGrid page={page} /> | ||
</Suspense> | ||
<PaginationCarousel | ||
className='my-6' | ||
totalPages={Math.ceil(articleData.length / 6)} | ||
t={{ | ||
goToPreviousPage: t('goToPreviousPage'), | ||
previous: t('previous'), | ||
morePages: t('morePages'), | ||
goToNextPage: t('goToNextPage'), | ||
next: t('next'), | ||
page: t('page'), | ||
}} | ||
/> | ||
</> | ||
); | ||
} |
Oops, something went wrong.