-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite_html.sh
More file actions
executable file
·33 lines (26 loc) · 946 Bytes
/
write_html.sh
File metadata and controls
executable file
·33 lines (26 loc) · 946 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
#!/bin/bash
# Define the header file and the suffix
HEADER="global.header.html"
SUFFIX=".html"
# Ensure the header file exists
if [ ! -f "$HEADER" ]; then
echo "Header file '$HEADER' not found!"
exit 1
fi
# Process each content file matching the glob pattern
find posts -type f -name '*.md' | while read -r CONTENT; do
if [ -f "$CONTENT" ]; then
# Extract the base filename without the extension
BASENAME=$(basename "$CONTENT" .md)
DIRNAME=$(dirname "$CONTENT")
# Define the output filename
OUTPUT="${DIRNAME}/${BASENAME}${SUFFIX}"
# Concatenate header and content to create the new file
cat "$HEADER" "$CONTENT" > "$OUTPUT"
echo "Created '$OUTPUT' with header and contents from '$CONTENT'"
else
echo "No matching content files found in 'contents' directory."
exit 1
fi
done
echo "All files processed successfully."