Compare commits

..

3 commits

Author SHA1 Message Date
grassblock
e72c80197b feat: add PWA support 2025-06-04 18:17:39 +08:00
grassblock
9590e739b0 feat: add full favicon support 2025-06-04 18:17:29 +08:00
grassblock
c50855a5de chore(docs): update roadmap 2025-06-04 17:06:25 +08:00
10 changed files with 81 additions and 13 deletions

View file

@ -62,13 +62,13 @@ All commands are run from the root of the project, from a terminal:
- [x] A mode to make the site 0 javascript - [x] A mode to make the site 0 javascript
- [x] Multiple authors via YAML - [x] Multiple authors via YAML
- [ ] i18n support - [ ] i18n support
- [ ] Integrate with Fediverse w/ activityPub
- [ ] Plain text version when visiting the site via `curl`
- [x] Better support for printing version - [x] Better support for printing version
- [ ] Add support for more comment engines - [ ] Add support for more comment engines
- [ ] Add support for umami statics - [x] Add support for umami statics
- [ ] Improve documentation - [ ] Improve documentation
- [ ] Release v1.0 - [ ] Release v1.0
- [ ] ~~Integrate with Fediverse w/ activityPub~~
- [ ] ~~Plain text version when visiting the site via `curl`~~
## 👀 Want to learn more? ## 👀 Want to learn more?

View file

@ -18,6 +18,7 @@
"@astrojs/sitemap": "^3.3.1", "@astrojs/sitemap": "^3.3.1",
"@fontsource-variable/jetbrains-mono": "^5.2.5", "@fontsource-variable/jetbrains-mono": "^5.2.5",
"astro": "^5.2.5", "astro": "^5.2.5",
"ico-endec": "^0.1.6",
"sharp": "^0.34.1", "sharp": "^0.34.1",
"ultrahtml": "^1.6.0" "ultrahtml": "^1.6.0"
}, },

8
pnpm-lock.yaml generated
View file

@ -29,6 +29,9 @@ importers:
astro: astro:
specifier: ^5.2.5 specifier: ^5.2.5
version: 5.7.10(@azure/identity@4.9.1)(@types/node@22.15.3)(rollup@4.40.1)(typescript@5.8.3)(yaml@2.7.1) version: 5.7.10(@azure/identity@4.9.1)(@types/node@22.15.3)(rollup@4.40.1)(typescript@5.8.3)(yaml@2.7.1)
ico-endec:
specifier: ^0.1.6
version: 0.1.6
sharp: sharp:
specifier: ^0.34.1 specifier: ^0.34.1
version: 0.34.1 version: 0.34.1
@ -1838,6 +1841,9 @@ packages:
resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==}
engines: {node: '>=10.17.0'} engines: {node: '>=10.17.0'}
ico-endec@0.1.6:
resolution: {integrity: sha512-ZdLU38ZoED3g1j3iEyzcQj+wAkY2xfWNkymszfJPoxucIUhK7NayQ+/C4Kv0nDFMIsbtbEHldv3V8PU494/ueQ==}
ieee754@1.2.1: ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
@ -5179,6 +5185,8 @@ snapshots:
human-signals@2.1.0: {} human-signals@2.1.0: {}
ico-endec@0.1.6: {}
ieee754@1.2.1: {} ieee754@1.2.1: {}
import-meta-resolve@4.1.0: {} import-meta-resolve@4.1.0: {}

View file

@ -1,9 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 128 128">
<path d="M50.4 78.5a75.1 75.1 0 0 0-28.5 6.9l24.2-65.7c.7-2 1.9-3.2 3.4-3.2h29c1.5 0 2.7 1.2 3.4 3.2l24.2 65.7s-11.6-7-28.5-7L67 45.5c-.4-1.7-1.6-2.8-2.9-2.8-1.3 0-2.5 1.1-2.9 2.7L50.4 78.5Zm-1.1 28.2Zm-4.2-20.2c-2 6.6-.6 15.8 4.2 20.2a17.5 17.5 0 0 1 .2-.7 5.5 5.5 0 0 1 5.7-4.5c2.8.1 4.3 1.5 4.7 4.7.2 1.1.2 2.3.2 3.5v.4c0 2.7.7 5.2 2.2 7.4a13 13 0 0 0 5.7 4.9v-.3l-.2-.3c-1.8-5.6-.5-9.5 4.4-12.8l1.5-1a73 73 0 0 0 3.2-2.2 16 16 0 0 0 6.8-11.4c.3-2 .1-4-.6-6l-.8.6-1.6 1a37 37 0 0 1-22.4 2.7c-5-.7-9.7-2-13.2-6.2Z" />
<style>
path { fill: #000; }
@media (prefers-color-scheme: dark) {
path { fill: #FFF; }
}
</style>
</svg>

Before

Width:  |  Height:  |  Size: 749 B

BIN
src/assets/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

2
src/assets/favicon.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -1,4 +1,15 @@
--- ---
import Favicon from "../../../assets/favicon.png";
import FaviconSvg from '../../../assets/favicon.svg';
import {getImage} from "astro:assets";
const appleTouchIcon = await getImage({
src: Favicon,
width: 180,
height: 180,
format: 'png'
})
interface Props { interface Props {
title: string; title: string;
description: string; description: string;
@ -13,6 +24,11 @@ const canonicalURL = new URL(Astro.url.pathname, Astro.site);
<meta name="title" content={title} /> <meta name="title" content={title} />
{author && <meta name="author" content={author} />} {author && <meta name="author" content={author} />}
<meta name="description" content={description} /> <meta name="description" content={description} />
{/* PWA */}
<link rel="icon" href="/favicon.ico" sizes="32x32" />
<link rel="icon" href={FaviconSvg.src} type="image/svg+xml" />
<link rel="apple-touch-icon" href={appleTouchIcon.src} />
<link rel="manifest" href="/manifest.json" />
{/* Open Graph / Facebook */} {/* Open Graph / Facebook */}
<meta name="og:title" content={title} /> <meta name="og:title" content={title} />
<meta name="og:description" content={description} /> <meta name="og:description" content={description} />

View file

@ -39,7 +39,6 @@ const { title = pageTitle, author = siteConfig.defaultAuthor.name,description =
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<Meta title={pageTitle} author={author} description={description} ogImage={ogImage} /> <Meta title={pageTitle} author={author} description={description} ogImage={ogImage} />
<title>{pageTitle}</title> <title>{pageTitle}</title>

17
src/pages/favicon.ico.js Normal file
View file

@ -0,0 +1,17 @@
import sharp from 'sharp'
import ico from 'ico-endec'
import path from 'node:path'
// relative to project root
const faviconSrc = path.resolve('src/assets/favicon.svg')
export const GET = async () => {
// resize to 32px PNG
const buffer = await sharp(faviconSrc).resize(32).toFormat('png').toBuffer()
// generate ico
const icoBuffer = ico.encode([buffer])
return new Response(icoBuffer, {
headers: { 'Content-Type': 'image/x-icon' }
})
}

View file

@ -0,0 +1,34 @@
import { getImage } from 'astro:assets'
import favicon from '../assets/favicon.png'
import { siteConfig } from "../config.js";
// thanks to https://kremalicious.com/favicon-generation-with-astro
const faviconPngSizes = [192, 512]
export const GET = async () => {
const icons = await Promise.all(
faviconPngSizes.map(async (size) => {
const image = await getImage({
src: favicon,
width: size,
height: size,
format: 'png'
})
return {
src: image.src,
type: `image/${image.options.format}`,
sizes: `${image.options.width}x${image.options.height}`
}
})
)
const manifest = {
name: siteConfig.title,
description: siteConfig.description,
start_url: '/',
display: 'standalone',
id: 'deadbeef-d7d8-4d48-8a7a-593be33d9f77',
icons
}
return new Response(JSON.stringify(manifest))
}