diff --git a/src/components/ArticleCard.astro b/src/components/ArticleCard.astro index 1a64fc7..3fb9dd5 100644 --- a/src/components/ArticleCard.astro +++ b/src/components/ArticleCard.astro @@ -2,16 +2,15 @@ import Card from "./Card.astro"; import type { Post } from "../esa-utils/models"; import { getFirstImg } from "../esa-utils/thumbnail"; -import backgroundImage from "../assets/background.svg"; export interface Props { post: Post; } const { post } = Astro.props; const firstImg = await getFirstImg(post); -const img = firstImg ?? backgroundImage; +const img = firstImg; const href = `/posts/${post.number}`; const title = post.name; --- - + diff --git a/src/components/Card.astro b/src/components/Card.astro index 598f9be..50d1f11 100644 --- a/src/components/Card.astro +++ b/src/components/Card.astro @@ -1,15 +1,28 @@ --- +import { Image } from "astro:assets"; +import Icon from "../../public/YN-icon.png"; export interface Props { href: string | URL; title: string; - imgSrc: string; + imgSrc: string | undefined; } const { href, title, imgSrc } = Astro.props; +const useFallbackImage = imgSrc === undefined || imgSrc === ""; ---

{title}

- + { + useFallbackImage ? ( +
+
+ +
+
+ ) : ( + + ) + }
diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 7fe34d7..73c1951 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -106,6 +106,7 @@ const jsonldStringfy = JSON.stringify({ --border-color-accent: light-dark(#777, #aaa); --theme-color: light-dark(#0e9c26, #2db446); --theme-color-accent: light-dark(#0b7a1f, #52cc68); + --fallback-bg: light-dark(#c3c3c3, #484848); *, *::before, *::after { diff --git a/src/pages/index.astro b/src/pages/index.astro index c4123d6..4bcfd7b 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -4,14 +4,13 @@ import Layout from "../layouts/Layout.astro"; import ArticleCard from "../components/ArticleCard.astro"; import { getFirstImg } from "../esa-utils/thumbnail"; import { fetchPost } from "../esa-utils/fetch"; -import backgroundImage from "../assets/background.svg"; import Card from "../components/Card.astro"; const response = await fetchPosts(); const posts = response.posts; const faqPost = await fetchPost(import.meta.env.ESA_FAQ_NUMBER); const faqFirstImg = await getFirstImg(faqPost); -const faqImg = faqFirstImg ?? backgroundImage; +const faqImg = faqFirstImg; const blogPosts = posts.filter((post) => post.number !== faqPost.number); --- @@ -20,7 +19,7 @@ const blogPosts = posts.filter((post) => post.number !== faqPost.number);

記事一覧

{blogPosts.map((post) => )}

これってどうなの?

- +