From 80e60264eb0092b7975a5951bd916fa33d3f3f55 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Sat, 26 Jul 2025 17:11:27 +0900 Subject: [PATCH] #71 --- frontend/src/components/TagLink.tsx | 26 ++++++++++++++++------ frontend/src/pages/posts/PostListPage.tsx | 4 +++- frontend/src/pages/wiki/WikiDetailPage.tsx | 17 +++++++++----- 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/TagLink.tsx b/frontend/src/components/TagLink.tsx index 33879a9..881ce03 100644 --- a/frontend/src/components/TagLink.tsx +++ b/frontend/src/components/TagLink.tsx @@ -3,18 +3,28 @@ import { Link } from 'react-router-dom' import { LIGHT_COLOUR_SHADE, DARK_COLOUR_SHADE, TAG_COLOUR } from '@/consts' import { cn } from '@/lib/utils' +import type { ComponentProps, HTMLAttributes } from 'react' + import type { Tag } from '@/types' -type Props = { tag: Tag - linkFlg?: boolean - withWiki?: boolean - withCount?: boolean } +type CommonProps = { tag: Tag + withWiki?: boolean + withCount?: boolean } + +type PropsWithLink = + CommonProps & { linkFlg?: true } & Partial> + +type PropsWithoutLink = + CommonProps & { linkFlg: false } & Partial> + +type Props = PropsWithLink | PropsWithoutLink export default ({ tag, linkFlg = true, withWiki = true, - withCount = true }: Props) => { + withCount = true, + ...props }: Props) => { const spanClass = cn ( `text-${ TAG_COLOUR[tag.category] }-${ LIGHT_COLOUR_SHADE }`, `dark:text-${ TAG_COLOUR[tag.category] }-${ DARK_COLOUR_SHADE }`) @@ -35,11 +45,13 @@ export default ({ tag, {linkFlg ? ( + className={linkClass} + {...props}> {tag.name} ) : ( - + {tag.name} )} {withCount && ( diff --git a/frontend/src/pages/posts/PostListPage.tsx b/frontend/src/pages/posts/PostListPage.tsx index feba917..51556b8 100644 --- a/frontend/src/pages/posts/PostListPage.tsx +++ b/frontend/src/pages/posts/PostListPage.tsx @@ -102,7 +102,9 @@ export default () => {
- Wiki を見る + + Wiki を見る +
)} diff --git a/frontend/src/pages/wiki/WikiDetailPage.tsx b/frontend/src/pages/wiki/WikiDetailPage.tsx index 1bfe735..9ad1c6d 100644 --- a/frontend/src/pages/wiki/WikiDetailPage.tsx +++ b/frontend/src/pages/wiki/WikiDetailPage.tsx @@ -102,20 +102,25 @@ export default () => { {(wikiPage && version) && (
{wikiPage.pred ? ( - + < 古 - ) : <>(最古)} + ) : '(最古)'} {wikiPage.updatedAt} {wikiPage.succ ? ( - + 新 > - ) : <>(最新)} + ) : '(最新)'}
)} - +
{wikiPage === undefined @@ -123,7 +128,7 @@ export default () => { : }
- {posts.length > 0 && ( + {(!(version) && posts.length > 0) && (