Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/mrgnw/scripts.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445#!/usr/bin/env zsh# inspired by# https://evilmartians.com/chronicles/how-to-favicon-in-2021-six-files-that-fit-most-needs
generate_favicon() { bunx svgo --multipass icon.svg png_sizes=(512 192 180 32 16) for size in $png_sizes; do rsvg-convert icon.svg -w $size -h $size -o "icon-${size}.png" done
optimizt *.png
convert "icon-32.png" "icon-16.png" favicon.ico}
favicon_manifest() { local target_dir="${1:-$PWD}" local manifest_file="${target_dir}/manifest.webmanifest"
# if manifest_file doesn't exist, create it with the following: cat > "$manifest_file" <<EOF{ "icons": [ { "src": "/icon-192.png", "type": "image/png", "sizes": "192x192" }, { "src": "/icon-512.png", "type": "image/png", "sizes": "512x512" } ]}EOF jq . "$manifest_file" > "$manifest_file.tmp" && mv "$manifest_file.tmp" "$manifest_file"}
generate_favicon
favicon_manifest