Moved nice tools from fgo-ta over

This commit is contained in:
Firq 2024-01-05 01:12:19 +01:00
parent e406bd8764
commit 7ed78bceff
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20
10 changed files with 72 additions and 41 deletions
src/components

View file

@ -1,6 +1,7 @@
---
import type { ImageMetadata } from 'astro'
import { Image } from 'astro:assets'
import type { GlobImage } from '../types/generic'
import { plsLoadImage } from '../utils/tools'
export interface Props {
title: string
@ -11,14 +12,15 @@ export interface Props {
const { imageFile, link, title } = Astro.props
const logoAltText = `${title} Logo`
const imagePath = `/src/assets/technologies/${imageFile}`
const images_logos = import.meta.glob<{ default: ImageMetadata }>(
const images_logos = import.meta.glob<GlobImage>(
'/src/assets/technologies/*.{png,webp}'
)
const loadedImage = plsLoadImage(images_logos, imagePath)
---
<a href={link} target="_blank" rel="noopener noreferrer" aria-label={title}>
<article>
<Image src={images_logos[imagePath]()} alt={logoAltText} />
<Image src={loadedImage} alt={logoAltText} />
<div>
<h2>{title}</h2>
</div>