-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_projetos_json
More file actions
executable file
·44 lines (33 loc) · 871 Bytes
/
update_projetos_json
File metadata and controls
executable file
·44 lines (33 loc) · 871 Bytes
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
40
41
42
43
44
#!/bin/bash
CWD="$PWD"
DIR="assets/projetos"
OUTPUT="$CWD/deploy/src/assets/projetos.json"
cd deploy/src
echo "[" > "$OUTPUT"
first=true
find "$DIR" -type f -name "*.md" | while read -r file; do
title=$(grep -m1 '^#' "$file" | sed 's/^# *//; s/"/\\"/g')
subtitle=$(grep -m1 '^##' "$file" | sed 's/^## *//; s/"/\\"/g')
dir=$(dirname "$file")
banner_path="$dir/banner.webp"
if [ ! -f "$banner_path" ]; then
banner_path=null
else
banner_path="$banner_path"
fi
if [ "$first" = true ]; then
first=false
else
echo "," >> "$OUTPUT"
fi
echo -e \
" {
\"title\": \"$title\",
\"subtitle\": \"$subtitle\",
\"link\": \"$file\",
\"banner\":\"$banner_path\",
}" >> "$OUTPUT"
done
# Fecha o JSON
echo "]" >> "$OUTPUT"
echo "Arquivo $OUTPUT gerado com sucesso!"