diff --git a/README.md b/README.md index 9805641..d80199d 100644 --- a/README.md +++ b/README.md @@ -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] Multiple authors via YAML - [ ] i18n support -- [ ] Integrate with Fediverse w/ activityPub -- [ ] Plain text version when visiting the site via `curl` - [x] Better support for printing version - [ ] Add support for more comment engines -- [ ] Add support for umami statics +- [x] Add support for umami statics - [ ] Improve documentation - [ ] Release v1.0 +- [ ] ~~Integrate with Fediverse w/ activityPub~~ +- [ ] ~~Plain text version when visiting the site via `curl`~~ ## 👀 Want to learn more? diff --git a/package.json b/package.json index 8f7df2f..e72833f 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@astrojs/sitemap": "^3.3.1", "@fontsource-variable/jetbrains-mono": "^5.2.5", "astro": "^5.2.5", + "ico-endec": "^0.1.6", "sharp": "^0.34.1", "ultrahtml": "^1.6.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ed376d1..4e77c2e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -29,6 +29,9 @@ importers: astro: 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) + ico-endec: + specifier: ^0.1.6 + version: 0.1.6 sharp: specifier: ^0.34.1 version: 0.34.1 @@ -1838,6 +1841,9 @@ packages: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} + ico-endec@0.1.6: + resolution: {integrity: sha512-ZdLU38ZoED3g1j3iEyzcQj+wAkY2xfWNkymszfJPoxucIUhK7NayQ+/C4Kv0nDFMIsbtbEHldv3V8PU494/ueQ==} + ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} @@ -5179,6 +5185,8 @@ snapshots: human-signals@2.1.0: {} + ico-endec@0.1.6: {} + ieee754@1.2.1: {} import-meta-resolve@4.1.0: {} diff --git a/public/favicon.svg b/public/favicon.svg deleted file mode 100644 index f157bd1..0000000 --- a/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - diff --git a/src/assets/favicon.png b/src/assets/favicon.png new file mode 100644 index 0000000..1591ebf Binary files /dev/null and b/src/assets/favicon.png differ diff --git a/src/assets/favicon.svg b/src/assets/favicon.svg new file mode 100644 index 0000000..ed62e71 --- /dev/null +++ b/src/assets/favicon.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/components/helper/head/Meta.astro b/src/components/helper/head/Meta.astro index a790d7b..ec611c9 100644 --- a/src/components/helper/head/Meta.astro +++ b/src/components/helper/head/Meta.astro @@ -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 { title: string; description: string; @@ -13,6 +24,11 @@ const canonicalURL = new URL(Astro.url.pathname, Astro.site); {author && } +{/* PWA */} + + + + {/* Open Graph / Facebook */} diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 7847a12..365b6af 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -39,7 +39,6 @@ const { title = pageTitle, author = siteConfig.defaultAuthor.name,description = - {pageTitle} diff --git a/src/pages/favicon.ico.js b/src/pages/favicon.ico.js new file mode 100644 index 0000000..f63df3c --- /dev/null +++ b/src/pages/favicon.ico.js @@ -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' } + }) +} diff --git a/src/pages/manifest.json.js b/src/pages/manifest.json.js new file mode 100644 index 0000000..2fcf083 --- /dev/null +++ b/src/pages/manifest.json.js @@ -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)) +} \ No newline at end of file