forked from startup-systems/static
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.sh
More file actions
executable file
·35 lines (25 loc) · 748 Bytes
/
generate.sh
File metadata and controls
executable file
·35 lines (25 loc) · 748 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
#!/bin/bash
#set -ex
# Create Target directories recursively
mkdir -p "$2"
# Loop through all files in Input directory
for file in "$1"/*
do
fname=$(basename "$file")
printf "\nProcessing %s...\n" "$fname"
str=$(echo "$fname" | rev | cut -d"." -f2- | rev)
cp template.html "$2/$str.html"
# Parse all files line by line and save to an array
i=0
while IFS=$'\n' read -r line || [[ -n "$line" ]];
do
if [ "$line" != "" ]; then
if [ "$i" == 0 ]; then
sed -i "s/{{title}}/$line/g" "$2/$str.html"
else
sed -i "s/{{body}}/$line/g" "$2/$str.html"
fi
fi
i=$((i+1))
done < "$file"
done