Skip to content

Commit

Permalink
Merge pull request #59 from OUCC/ciffelia/fix-icon-alt
Browse files Browse the repository at this point in the history
著者とタグのアイコンの代替テキストがファイル名になっていたり存在していなかったりするのを修正
  • Loading branch information
ciffelia authored Dec 7, 2023
2 parents 586e76d + d2f2c12 commit 9b08c88
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/components/blog/icon/AuthorIcon.astro
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const image =
image.type === 'svg' ? (
<Icon
name={image.name}
alt={`${image.name} のアイコン`}
alt={`${author.name} のアイコン`}
class="aspect-square rounded-full"
height={size}
width={size}
Expand All @@ -30,6 +30,7 @@ const image =
) : image.type === 'external-url' ? (
<img
src={image.url}
alt={`${author.name} のアイコン`}
height={size}
width={size}
class="aspect-square rounded-full"
Expand Down
23 changes: 15 additions & 8 deletions src/components/blog/icon/TagIcon.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,34 @@
import Icon from '@/components/common/Icon.astro'
import { unreachable } from '@/utils/unreachable'
import type { CollectionEntry } from 'astro:content'
interface Props {
tagImage: CollectionEntry<'tags'>['data']['image']
tag: CollectionEntry<'tags'>['data']
size: number
}
const { tagImage, size } = Astro.props
const { tag, size } = Astro.props
---

{
tagImage.type === 'svg' ? (
tag.image.type === 'svg' ? (
<Icon
name={tagImage.name}
alt={`${tagImage.name} のアイコン`}
name={tag.image.name}
alt={`${tag.name} のアイコン`}
class="aspect-square"
width={size}
height={size}
isBlog
/>
) : tagImage.type === 'external-url' ? (
<img src={tagImage.url} height={size} width={size} class="aspect-square" />
) : tag.image.type === 'external-url' ? (
<img
src={tag.image.url}
alt={`${tag.name} のアイコン`}
height={size}
width={size}
class="aspect-square"
/>
) : (
unreachable(tagImage)
unreachable(tag.image)
)
}
2 changes: 1 addition & 1 deletion src/components/blog/tag/TagListItemCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const { id, articleCount, ...tag } = Astro.props
class="block sm:basis-[calc((100%-0.75rem)/2)] bg-white rounded-xl border space-y-1 group"
>
<a class="w-full h-full p-4 flex items-center" href={`/blog/tags/${id}`}>
<TagIcon tagImage={tag.image} size={40} />
<TagIcon tag={tag} size={40} />
<div class="px-2">
<h2 class="text-xl font-bold line-clamp-1 group-hover:underline">
{tag.name}
Expand Down
2 changes: 1 addition & 1 deletion src/components/blog/tag/TagSmallList.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const { tags } = Astro.props
href={`/blog/tags/${tag.id}`}
class="flex items-center gap-1 bg-gray-100 hover:bg-gray-200 text-sm text-justify p-1 rounded-full"
>
<TagIcon tagImage={tag.data.image} size={18} />
<TagIcon tag={tag.data} size={18} />
<p>{tag.data.name}</p>
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blog/tags/[slug]/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const isShowAbout = tag.description || tag.site || tag.document || tag.github
summarySize="summary"
>
<BlogTitle title={tag.name} background="white">
<Fragment slot="icon"><TagIcon tagImage={tag.image} size={80} /></Fragment>
<Fragment slot="icon"><TagIcon tag={tag} size={80} /></Fragment>
</BlogTitle>
<main class="flex flex-col h-full">
{isShowAbout && <TagAboutSection tag={tag} />}
Expand Down

0 comments on commit 9b08c88

Please sign in to comment.