Skip to content

Commit 2774a7e

Browse files
committed
Bring back white background for social previews
1 parent da57f73 commit 2774a7e

File tree

6 files changed

+19
-8
lines changed

6 files changed

+19
-8
lines changed

assets/opengraph-en.svg

+1
Loading

assets/opengraph-tr.svg

+1
Loading

assets/twitter-en.svg

+1
Loading

assets/twitter-tr.svg

+1
Loading

build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ if [[ -d bin ]]; then
2626
fi
2727

2828
echo "Generating images..."
29-
./gen-icon.sh assets/opengraph-*.svg assets/twitter-*.svg &
29+
./gen-icon.sh --background white assets/opengraph-*.svg assets/twitter-*.svg &
3030
asset_job=$!
3131
./gen-icon.sh favicon/favicon.svg --sizes=512,256,255,192,180,150,128,96,72,64,48,32,24,20,16 --apple &
3232
favicon_job=$!

gen-icon.sh

+14-7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Options:
1313
values. Original size from the SVG file is used when this option is
1414
missing or 0 is used.
1515
16+
-b, --background=<COLOR>
17+
Background color to use while rendering SVG.
18+
1619
-a, --apple=[SIZE,PADDING]
1720
Apple touch icon size to generate. "180,25" is used when no size or
1821
padding argument is given. Padding is automatically calculated as 1/7
@@ -29,13 +32,13 @@ if [[ $? -ne 4 ]]; then
2932
exit 1
3033
fi
3134

32-
opts=$(getopt -o 'hs:a::' -l 'help,sizes:,apple::' -n "$app_name" -- "$@") || exit $?
35+
args=()
36+
opts=$(getopt -o 'hs:b:a::' -l 'help,sizes:,background:,apple::' -n "$app_name" -- "$@") || exit $?
3337

3438
eval "opts=($opts)"
3539

36-
args=()
37-
apple=0
3840
sizes=0
41+
apple=0
3942

4043
for ((i = 0; i < ${#opts[@]}; i++)); do
4144
opt="${opts["$i"]}"
@@ -45,6 +48,10 @@ for ((i = 0; i < ${#opts[@]}; i++)); do
4548
readarray -t -d, png_sizes < <(printf "%s" "${opts["$i"]}")
4649
sizes=1
4750
;;
51+
-b|--background)
52+
((i++))
53+
background="${opts["$i"]}"
54+
;;
4855
-a|--apple)
4956
((i++))
5057
readarray -t -d, apple_sizes < <(printf "%s" "${opts["$i"]}")
@@ -55,7 +62,7 @@ for ((i = 0; i < ${#opts[@]}; i++)); do
5562
exit 0
5663
;;
5764
--)
58-
args+=("${opts[@]:((i+1))}")
65+
args+=("${opts[@]:i+1}")
5966
break
6067
;;
6168
esac
@@ -86,11 +93,11 @@ fi
8693
status=0
8794

8895
export_png() {
89-
if [[ $2 -nt $3 ]]; then
96+
if [[ $2 -nt $3 || ${BASH_SOURCE[0]} -nt $3 ]]; then
9097
if (( $1 == 0 )); then
91-
resvg "$2" "$3"
98+
resvg ${background:+--background "$background"} "$2" "$3"
9299
else
93-
resvg -w "$1" -h "$1" "$2" "$3"
100+
resvg ${background:+--background "$background"} -w "$1" -h "$1" "$2" "$3"
94101
fi
95102
fi
96103
}

0 commit comments

Comments
 (0)