We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5f7f81c commit 7596dccCopy full SHA for 7596dcc
assets/scripts/insert_navbar.sh
@@ -78,14 +78,16 @@ find "$HTML_DIR" -name "*.html" | while read file; do
78
file_contents=$(cat "$file")
79
80
# Insert the navbar HTML after the <body> tag
81
- updated_contents="${file_contents/<body>/<body>
82
-$NAVBAR_HTML
83
-}"
84
-
85
- # Write the updated contents back to the file
86
- echo "$updated_contents" > "$file"
+ awk -v nav="$NAVBAR_HTML" '
+ /<body>/ {
+ print $0
+ print nav
+ next
+ }
87
+ { print }
88
+ ' "$file" > temp && mv temp "$file"
89
90
# Remove trailing blank lines immediately after the navbar
91
awk 'BEGIN {RS=""; ORS="\n\n"} {gsub(/\n+$/, ""); print}' "$file" > temp_cleaned && mv temp_cleaned "$file"
92
echo "Inserted new navbar into $file"
-done
93
+done
0 commit comments