mirror of
https://github.com/Fluffy-Bean/website.git
synced 2025-06-26 20:06:18 +00:00
Fix issues brought up by astro build
Use Astro image and picture elements Move images to assets folder
This commit is contained in:
parent
3acfb73ce8
commit
457591297a
17 changed files with 86 additions and 53 deletions
|
@ -1,15 +1,22 @@
|
|||
---
|
||||
import "../styles/styles.scss";
|
||||
import { Picture, getImage } from 'astro:assets';
|
||||
|
||||
import { Image } from "astro:assets";
|
||||
import "../styles/styles.scss";
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
src?: string,
|
||||
image: string,
|
||||
alt: string,
|
||||
}
|
||||
|
||||
const { title, src, alt } = Astro.props;
|
||||
const { title, image, alt } = Astro.props;
|
||||
|
||||
let imageData = await getImage({
|
||||
src: image,
|
||||
format: "jpeg",
|
||||
width: 1080,
|
||||
height: 700,
|
||||
});
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
|
@ -20,7 +27,7 @@ const { title, src, alt } = Astro.props;
|
|||
<meta name="viewport" content="width=device-width" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="icon" type="image/webp" href="/src/assets/leg.webp" />
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
|
||||
|
@ -29,19 +36,26 @@ const { title, src, alt } = Astro.props;
|
|||
</head>
|
||||
<body>
|
||||
<div class="banner">
|
||||
{src && (
|
||||
<Image src={src} width="1080" height="700" loading="eager" alt={alt} />
|
||||
<script>
|
||||
const img = document.querySelector(".banner > img");
|
||||
document.addEventListener("scroll", () => {
|
||||
img.style.top = `${window.scrollY}px`;
|
||||
img.style.filter = `blur(${window.scrollY / 100}px)`;
|
||||
})
|
||||
</script>
|
||||
)}
|
||||
<Picture
|
||||
src={imageData.src}
|
||||
alt={alt}
|
||||
width={1080}
|
||||
height={700}
|
||||
widths={[240, 540, 720, 1080]}
|
||||
sizes={`(max-width: 360px) 240px, (max-width: 720px) 540px, (max-width: 1600px) 720px, 1080px`}
|
||||
formats={['jpeg', 'webp']}
|
||||
loading="eager"
|
||||
/>
|
||||
</div>
|
||||
<main>
|
||||
<slot />
|
||||
</main>
|
||||
</body>
|
||||
<script>
|
||||
const img = document.querySelector(".banner > picture > img") as HTMLImageElement;
|
||||
document.addEventListener("scroll", () => {
|
||||
img.style.top = `${window.scrollY}px`;
|
||||
img.style.filter = `blur(${window.scrollY / 100}px)`;
|
||||
})
|
||||
</script>
|
||||
</html>
|
||||
|
|
|
@ -3,6 +3,9 @@ import HomeButton from "../components/HomeButton.astro";
|
|||
|
||||
interface Props {
|
||||
post: any,
|
||||
prev?: any,
|
||||
next?: any,
|
||||
base: string,
|
||||
}
|
||||
|
||||
const { post, prev, next, base } = Astro.props;
|
||||
|
@ -36,18 +39,20 @@ const { Content } = await post.render();
|
|||
<li>
|
||||
{prev && (
|
||||
<a class="button" href=`${base}/${prev.slug}` id="prev">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 256 256"><path d="M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"></path></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 256 256">
|
||||
<path d="M224,128a8,8,0,0,1-8,8H59.31l58.35,58.34a8,8,0,0,1-11.32,11.32l-72-72a8,8,0,0,1,0-11.32l72-72a8,8,0,0,1,11.32,11.32L59.31,120H216A8,8,0,0,1,224,128Z"></path>
|
||||
</svg>
|
||||
Last
|
||||
<!--{ prev.data.title }-->
|
||||
</a>
|
||||
)}
|
||||
</li>
|
||||
<li>
|
||||
{next && (
|
||||
<a class="button" href=`${base}/${next.slug}` id="next">
|
||||
<!--{ next?.data.title }-->
|
||||
Next
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 256 256"><path d="M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"></path></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 256 256">
|
||||
<path d="M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"></path>
|
||||
</svg>
|
||||
</a>
|
||||
)}
|
||||
</li>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue