chore: change avatar to webp format for speeding.

This commit is contained in:
Yufan Sheng 2024-07-03 02:52:43 +08:00
parent e6d0b7ffdb
commit 3934e25abc
Signed by: syhily
GPG Key ID: DEB186763C308C31
4 changed files with 7 additions and 4 deletions

View File

@ -182,6 +182,9 @@ You should host it on your own machine.
## Short-Term TODO Checklist ## Short-Term TODO Checklist
- [ ] Add clickable toc support for post.
- [ ] Add last modified time component for post.
- [ ] Add light box for images.
- [ ] Move comments into the new Astro content layer. - [ ] Move comments into the new Astro content layer.
- [ ] Check article grammar errors by using ChatGPT. Remain **42** posts. - [ ] Check article grammar errors by using ChatGPT. Remain **42** posts.
- [ ] Add music to the articles. Remain **42** posts. - [ ] Add music to the articles. Remain **42** posts.

View File

@ -187,7 +187,7 @@ const options: z.input<typeof Options> = {
size: 10, size: 10,
avatar: { avatar: {
mirror: 'https://weavatar.com/avatar', mirror: 'https://weavatar.com/avatar',
size: 80, size: 120,
}, },
}, },
}, },

View File

@ -18,7 +18,7 @@ const { comment, depth, pending } = Astro.props;
<div class="comment-avatar flex-avatar"> <div class="comment-avatar flex-avatar">
<img <img
alt={comment.nick} alt={comment.nick}
src={urlJoin(import.meta.env.SITE, 'avatar', `${comment.user_id}.png`)} src={urlJoin(import.meta.env.SITE, 'avatar', `${comment.user_id}.webp`)}
class="avatar avatar-40 photo" class="avatar avatar-40 photo"
height="40" height="40"
width="40" width="40"

View File

@ -18,7 +18,7 @@ const avatarImage = async (
const defaultAvatarLink = defaultAvatar(); const defaultAvatarLink = defaultAvatar();
const link = urlJoin( const link = urlJoin(
options.settings.comments.avatar.mirror, options.settings.comments.avatar.mirror,
`${hash}.png?s=${options.settings.comments.avatar.size}&d=${defaultAvatarLink}`, `${hash}?s=${options.settings.comments.avatar.size}&d=${defaultAvatarLink}`,
); );
const resp = await fetch(link, { redirect: 'manual', headers: { Referer: options.website } }); const resp = await fetch(link, { redirect: 'manual', headers: { Referer: options.website } });
@ -28,7 +28,7 @@ const avatarImage = async (
return new Response(Buffer.from(await resp.arrayBuffer()), { return new Response(Buffer.from(await resp.arrayBuffer()), {
headers: { headers: {
'Content-Type': 'image/png', 'Content-Type': 'image/webp',
'Cache-control': 'max-age=604800', 'Cache-control': 'max-age=604800',
}, },
}); });