Ajoute des icônes Apple Touch générées proprement

This commit is contained in:
2026-03-06 21:24:20 +01:00
parent 20ff3b861b
commit 42be182916
6 changed files with 56 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
{
"scripts": {
"icons:generate": "node tools/generate_apple_touch_icons.js",
"links:refresh": "node tools/check_external_links.js",
"stats:generate": "node tools/generate_stats.js"
},

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
static/apple-touch-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -11,4 +11,5 @@
<link rel="icon" href="{{ "favicon.ico" | absURL }}" type="image/x-icon">
<link rel="shortcut icon" href="{{ "favicon.ico" | absURL }}" type="image/x-icon">
<link rel="icon" href="{{ "favicon.png" | absURL }}" type="image/png" sizes="256x256">
<link rel="apple-touch-icon" href="{{ "apple-touch-icon.png" | absURL }}" sizes="180x180">
{{ partialCached "head/css.html" . }}

View File

@@ -4,4 +4,5 @@
<link rel="icon" href="{{ "favicon.ico" | absURL }}" type="image/x-icon" />
<link rel="shortcut icon" href="{{ "favicon.ico" | absURL }}" type="image/x-icon" />
<link rel="icon" href="{{ "favicon.png" | absURL }}" type="image/png" sizes="256x256" />
<link rel="apple-touch-icon" href="{{ "apple-touch-icon.png" | absURL }}" sizes="180x180" />
{{ partialCached "head/css.html" . }}

View File

@@ -0,0 +1,53 @@
#!/usr/bin/env node
const fs = require("fs");
const path = require("path");
const sharp = require("sharp");
const PROJECT_ROOT = path.resolve(__dirname, "..");
const SOURCE_ICON_PATH = path.join(PROJECT_ROOT, "static", "favicon.png");
const APPLE_TOUCH_ICON_SIZE = 180;
const APPLE_TOUCH_ICON_BACKGROUND = "#060c14";
const OUTPUT_ICON_PATHS = [
path.join(PROJECT_ROOT, "static", "apple-touch-icon.png"),
path.join(PROJECT_ROOT, "static", "apple-touch-icon-precomposed.png"),
];
/**
* Génère le PNG Apple Touch à partir du favicon principal du site.
*
* L'image finale est rendue opaque sur le fond sombre du thème actif pour
* éviter les rendus incohérents des zones transparentes sur certains appareils iOS.
*
* @returns {Promise<Buffer>}
*/
function buildAppleTouchIconBuffer() {
return sharp(SOURCE_ICON_PATH)
.resize(APPLE_TOUCH_ICON_SIZE, APPLE_TOUCH_ICON_SIZE, {
fit: "cover",
})
.flatten({
background: APPLE_TOUCH_ICON_BACKGROUND,
})
.png({
compressionLevel: 9,
adaptiveFiltering: true,
})
.toBuffer();
}
/**
* Écrit la même icône sous les deux noms historiques encore demandés par les navigateurs.
*
* @param {Buffer} iconBuffer
*/
function writeAppleTouchIcons(iconBuffer) {
for (const outputPath of OUTPUT_ICON_PATHS) {
fs.writeFileSync(outputPath, iconBuffer);
}
}
(async function main() {
const iconBuffer = await buildAppleTouchIconBuffer();
writeAppleTouchIcons(iconBuffer);
})();