Skip to content

Commit

Permalink
Merge pull request #117 from tatsutakein/feature/#106
Browse files Browse the repository at this point in the history
✨ Tags ページを追加
  • Loading branch information
tatsutakein authored Jun 29, 2023
2 parents b0391bd + 603fd62 commit 2cc3d90
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
44 changes: 44 additions & 0 deletions apps/frontend/src/app/tags/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Metadata, NextPage } from 'next';
import { ContentsLayout } from '@/components/Layout';
import { PagePath } from '@/lib/router';
import clsx from 'clsx';
import Link from 'next/link';

export const metadata: Metadata = {
title: 'Tags | tatsutakein.jp',
description: 'Ryo Takeuchi のポートフォリオサイトです。',
};

interface PageProps {
params: { slug: string[] };
searchParams: { [key: string]: string | string[] | undefined };
}

const Tags: NextPage<PageProps> = ({ params: { slug } }) => {
const tags = slug;

return (
<ContentsLayout
description=''
pageType='blog'
pageUrl={PagePath.tagResult(tags, true)}
>
<h1 className={clsx('text-4xl')}>Tags</h1>

{/* Tags */}
<div className={clsx('flex flex-wrap gap-4 text-sm', tags.length && 'mt-3')}>
{tags.map((tag) => (
<Link
key={tag}
href={PagePath.tagResult([tag])}
className='cursor-pointer hover:opacity-50'
>
# {tag}
</Link>
))}
</div>
</ContentsLayout>
);
};

export default Tags;
2 changes: 1 addition & 1 deletion apps/frontend/src/features/blog/components/HeroImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const HeroImage = ({
{tags.map((tag) => (
<Link
key={tag}
href={PagePath.tagResult(tag)}
href={PagePath.tagResult([tag])}
className='cursor-pointer hover:opacity-50'
>
# {tag}
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/lib/router/PagePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const PagePath = {
/**
* タグ検索結果ページ
*/
tagResult(tag: string, withOrigin?: boolean): string {
const path = `/tag/${tag}`;
tagResult(tags: string[], withOrigin?: boolean): string {
const path = `/tags/${tags.join('/')}`;
return withOrigin ? PagePath.withOrigin(path) : path;
},

Expand Down

1 comment on commit 2cc3d90

@vercel
Copy link

@vercel vercel bot commented on 2cc3d90 Jun 29, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.