Skip to content

Commit f302ea2

Browse files
committed
fix project fit and position
1 parent 10ff320 commit f302ea2

File tree

9 files changed

+33
-12
lines changed

9 files changed

+33
-12
lines changed

contents/projects/hackathon/2023-08-17/call-paper.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ title: Call Paper
33
date: 2023-08-17
44
kind: hackathon
55
status: finished
6+
67
image:
78
src: ./call-paper.png
9+
position: left
10+
811
description: 論文の引用関係を可視化できるアプリ
912
github: https://github.com/ut-code/call-paper
1013
website: https://call-paper.pages.dev

contents/projects/hackathon/2023-08-17/denigma.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ kind: hackathon
55
status: dead
66
image:
77
src: ./denigma.png
8+
position: left
9+
810
description: "暗号解読ゲーム。シーザー暗号やRSA暗号など、基本的な暗号に触れてみよう!"
911
github: https://github.com/ut-code/denigma
1012
website: https://utcode-denigma.onrender.com/

contents/projects/hackathon/2023-08-17/music-app.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ kind: hackathon
55
status: finished
66
image:
77
src: ./music-app.png
8+
position: top
9+
fit: contain
10+
bg: white
11+
812
description: その日の気分にあった作業用BGMを生成してくれるアプリ
913
github: https://github.com/ut-code/music-app
1014
website: https://ut-code.github.io/music-app

contents/projects/hackathon/2024-06-08/typing-script.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ date: 2024-06-08
66
description: ソースコードに特化したタイピング練習サイトです。
77
image:
88
src: ./typing-script.png
9+
fit: contain
10+
bg: white
11+
912
website: https://ut-code.github.io/TypingScript
1013
github: https://github.com/ut-code/TypingScript
1114
---

contents/projects/hackathon/2025-02-22/gemmit.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ status: released
66
description: "Git の差分から Gemini がコミットメッセージを考えてくれるツール"
77
image:
88
src: ./gemmit.png
9+
position: top
10+
bg: white
11+
912
members:
1013
- rtakanaka
1114
tags:

src/components/ArticleList.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,10 @@ const articlesWithExcerpts = await Promise.all(
8787
fit={article.data.fit}
8888
src={article.data.image}
8989
class:list={[
90-
"min-h-0 w-full rounded-xl",
90+
"aspect-5/3 min-h-0 w-full rounded-xl",
9191
!article.data["bg_color"] && "skeleton",
9292
]}
9393
style={{
94-
"aspect-ratio": "5 / 3",
9594
"object-fit": article.data.fit,
9695
...(article.data.bg_color
9796
? {

src/components/ProjectList.astro

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@ const { projects, variant = "full" } = props;
2929
height={(600 * 3) / 5}
3030
class:list={[
3131
"aspect-5/3 w-full",
32-
!project.data.image.bg && "skeleton",
32+
project.data.image.fit !== "contain" && "skeleton",
3333
]}
3434
style={{
3535
"object-fit": project.data.image.fit,
36-
...(project.data.image.bg
37-
? {
38-
"background-color": project.data.image.bg,
39-
}
40-
: {}),
36+
"object-position": project.data.image.position,
37+
"background-color": project.data.image.bg,
4138
}}
4239
/>
4340
<div class="p-4">

src/pages/projects/[...id].astro

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,16 @@ const { Content } = await render(project);
3333
<Picture
3434
loading="eager"
3535
formats={["avif", "webp"]}
36-
class="skeleton w-full object-cover lg:w-150 lg:rounded-2xl"
36+
class="skeleton aspect-5/3 w-full object-cover lg:w-150 lg:rounded-2xl"
3737
alt="プロジェクト画像"
3838
src={project.data.image.src}
39+
position={project.data.image.position}
40+
width="1000"
41+
height="600"
42+
style={{
43+
"object-position": project.data.image.position,
44+
"object-fit": project.data.image.fit,
45+
}}
3946
/>
4047
<div class="container mx-auto mt-8 px-4 lg:mx-0 lg:flex-1">
4148
<p class="flex items-center gap-1 text-gray-600">

src/schema.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export type Article = z.infer<ReturnType<typeof CreateArticleSchema>>;
77
export type Member = z.infer<ReturnType<typeof CreateMemberSchema>>;
88
export type Project = z.infer<ReturnType<typeof CreateProjectSchema>>;
99

10+
const Position = z.enum(["center", "top", "bottom", "left", "right"]);
11+
const Fit = z.enum(["cover", "contain", "fill", "none"]);
1012
export const CreateArticleSchema = ({ image }: { image: ImageFunction }) =>
1113
z
1214
.object({
@@ -19,8 +21,8 @@ export const CreateArticleSchema = ({ image }: { image: ImageFunction }) =>
1921
categories: z.array(z.string()).optional(),
2022
// 画像系
2123
image: image(),
22-
fit: z.enum(["cover", "contain", "fill", "none"]).optional(),
23-
position: z.enum(["center", "top", "bottom", "left", "right"]).optional(),
24+
fit: Fit.optional(),
25+
position: Position.default("center"),
2426
bg_color: z.string().optional(),
2527
})
2628
.refine(
@@ -51,7 +53,8 @@ export const CreateProjectSchema = ({ image }: { image: ImageFunction }) =>
5153
date: z.date(),
5254
image: z.object({
5355
src: image(),
54-
fit: z.enum(["cover", "contain", "fill"]).optional().default("cover"),
56+
position: Position.default("center"),
57+
fit: Fit.default("cover"),
5558
bg: z.string().optional().default("whitesmoke"),
5659
}),
5760
description: z.string(),

0 commit comments

Comments
 (0)