Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OUCCのロゴを<Image>で表示する #49

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/assets/icons/oucc.svg → src/assets/oucc.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 12 additions & 2 deletions src/components/common/Image.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type Props = Omit<HTMLAttributes<'img'>, 'src' | 'srcset'> & {

const { widths = [3840, 1920, 960, 480, 240], ...attrs } = Astro.props

const { src, attributes } = await getImage(attrs)
const { src, options, attributes } = await getImage(attrs)

const originalWidth = parseInt(attributes.width, 10)
const srcset = (
Expand All @@ -25,4 +25,14 @@ const srcset = (
).join(',')
---

<img src={src} srcset=`${src} ${originalWidth}w,${srcset}` {...attributes} />
{
options.format === 'svg' ? (
<img src={src} {...attributes} />
) : (
<img
src={src}
srcset={`${src} ${originalWidth}w,${srcset}`}
{...attributes}
/>
)
}
15 changes: 12 additions & 3 deletions src/components/index/about/AboutSection.astro
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
---
import type { ImageMetadata } from 'astro'
import Section from '@/components/common/Section.astro'
import Icon from '@/components/common/Icon.astro'
import Image from '@/components/common/Image.astro'
import ouccImage from '@/assets/oucc.svg'
import AboutCard from './AboutCard.astro'

interface Item {
icon: string
icon: string | ImageMetadata
description: string[]
}

const items: Item[] = [
{
icon: 'oucc',
icon: ouccImage,
description: [
'OUCC(大阪大学コンピュータクラブ)は、コンピュータを使ったものづくりに関心を持つ学生が交流するサークルです。',
'プログラミングやお絵描き、3Dモデリングなどの活動を行っています。',
Expand Down Expand Up @@ -43,7 +46,13 @@ const items: Item[] = [
items.map(({ icon, description }) => (
<li class="flex-1 max-w-[32rem] flex items-stretch">
<AboutCard>
<Icon slot="icon" name={icon} alt="" class="w-20 h-20" />
<Fragment slot="icon">
{typeof icon === 'string' ? (
<Icon name={icon} alt="" class="w-20 h-20" />
) : (
<Image src={icon} alt="" class="w-20 h-20 object-contain" />
)}
</Fragment>
{description.map((x) => (
<p>{x}</p>
))}
Expand Down
5 changes: 3 additions & 2 deletions src/components/layout/Footer.astro
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
import Icon from '@/components/common/Icon.astro'
import Image from '@/components/common/Image.astro'
import ouccImage from '@/assets/oucc.svg'
import FooterLink from './FooterLink.astro'
---

<footer class="py-8 flex flex-wrap justify-center items-center gap-8">
<div class="px-4 flex flex-wrap justify-center items-center gap-4">
<Icon name="oucc" alt="OUCC" class="w-12" />
<Image src={ouccImage} alt="OUCC" class="w-12" />
<span class="text-sm">© 2023 大阪大学コンピュータクラブ</span>
</div>
<div class="px-4 flex flex-wrap justify-center items-center gap-4">
Expand Down
10 changes: 5 additions & 5 deletions src/components/layout/nav/Header.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
import Icon from '@/components/common/Icon.astro'
import Image from '@/components/common/Image.astro'
import ouccImage from '@/assets/oucc.svg'
import LinkButton from '@/components/common/button/LinkButton.astro'
import Navigation from './Navigation.astro'

Expand Down Expand Up @@ -38,11 +40,9 @@ const {
/>
</button>
<a href={rootPath} class="flex items-center">
<Icon
name="oucc"
alt="OUCC"
class="block max-h-full min-h-full h-16 aspect-square"
/>
<span class="h-full aspect-square">
<Image src={ouccImage} alt="OUCC" class="h-full object-contain" />
</span>
{headerTitle && <h1 class="text-4xl font-bold mx-4">{headerTitle}</h1>}
</a>
</div>
Expand Down
5 changes: 3 additions & 2 deletions src/components/layout/nav/Navigation.astro
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
import Icon from '@/components/common/Icon.astro'
import Image from '@/components/common/Image.astro'
import ouccImage from '@/assets/oucc.svg'
import NavigationListItem from './NavigationListItem.astro'
import DrWani from './DrWani.astro'
---

<nav class="w-full h-full bg-white flex flex-col">
<div class="py-2 flex justify-center">
<Icon name="oucc" alt="OUCC" class="w-20 aspect-square" />
<Image src={ouccImage} alt="OUCC" class="w-20 h-20 object-contain" />
</div>
<ul class="flex flex-col text-center">
<NavigationListItem to="/">トップページ</NavigationListItem>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/blog/[slug]/_OgImageGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import satori from 'satori'
import oucc from '@/assets/icons/oucc.svg?raw'
import oucc from '@/assets/oucc.svg?raw'
import fs from 'node:fs/promises'
import sharp from 'sharp'

Expand Down