summaryrefslogtreecommitdiffstats
path: root/scripts/build_showcase.sh
blob: d4dabec6e1287ed67b2023aa1ded56cac2b7f818 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

mkdir -p showcase

mapfile -d $'\0' icon_files < <(find "output" \
    -type f \
    -name "*.svg" \
    -print0)

icons="[]"

for icon in "${icon_files[@]}"; do
    title=$icon
    title=${title#output/}
    title=${title%.svg}

    content=$(cat "$icon" | sed -z 's/\\/\\\\/g;s/\n/\\n/g;s/"/\\"/g')

    icons=$(echo "$icons" | jq ". += [ { \
        content: \"$content\", \
        title: \"$title\", \
    } ]")
done

meta_file=$(mktemp)

icons=$(echo "$icons" | jq "sort_by(.title)")

echo "{ icons: $icons }" > "$meta_file"

echo "" | pandoc \
    -f markdown \
    -t html5 \
    --no-highlight \
    --template "src/showcase/index.html" \
    -o "showcase/index.html" \
    --metadata-file "$meta_file"

rm "$meta_file"