Postbuild script updated
This commit is contained in:
		
							
								
								
									
										48
									
								
								postbuild.sh
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								postbuild.sh
									
									
									
									
									
								
							@@ -7,30 +7,40 @@ timestamp=$(date +%s)
 | 
				
			|||||||
# Define an array of folders to skip
 | 
					# Define an array of folders to skip
 | 
				
			||||||
skip_folders=("img" "svg" "fonts")
 | 
					skip_folders=("img" "svg" "fonts")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Function to add timestamp to CSS files and update HTML imports
 | 
					# Function to check if a path is within a skipped folder
 | 
				
			||||||
update_css_references() {
 | 
					is_skipped_folder() {
 | 
				
			||||||
	# Find all CSS files in the root of the public directory
 | 
						local path=$1
 | 
				
			||||||
	for css_file in "$public_dir"/*$css_extension; do
 | 
						for skip in "${skip_folders[@]}"; do
 | 
				
			||||||
		if [[ -f "$css_file" ]]; then
 | 
							if [[ "$path" == */$skip/* ]]; then
 | 
				
			||||||
			base_name=$(basename "$css_file" "$css_extension")
 | 
								return 0
 | 
				
			||||||
			new_name="${base_name}-${timestamp}${css_extension}"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			# Rename the CSS file
 | 
					 | 
				
			||||||
			mv "$css_file" "$public_dir/$new_name"
 | 
					 | 
				
			||||||
			echo "Renamed: $css_file -> $new_name"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			# Update all HTML files in the root and 'archiv' folder
 | 
					 | 
				
			||||||
			for html_file in "$public_dir"/*.html "$public_dir/archiv/"*.html; do
 | 
					 | 
				
			||||||
				if [[ -f "$html_file" ]]; then
 | 
					 | 
				
			||||||
					sed -i "s|$base_name$css_extension|$new_name|g" "$html_file"
 | 
					 | 
				
			||||||
					echo "Updated references in: $html_file"
 | 
					 | 
				
			||||||
		fi
 | 
							fi
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
 | 
						return 1
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Function to add timestamp to CSS files and update HTML imports
 | 
				
			||||||
 | 
					update_css_references() {
 | 
				
			||||||
 | 
						find "$public_dir" -type f -name "*$css_extension" | while read -r css_file; do
 | 
				
			||||||
 | 
							if is_skipped_folder "$css_file"; then
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
		fi
 | 
							fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							base_dir=$(dirname "$css_file")
 | 
				
			||||||
 | 
							base_name=$(basename "$css_file" "$css_extension")
 | 
				
			||||||
 | 
							new_name="${base_name}-${timestamp}${css_extension}"
 | 
				
			||||||
 | 
							new_path="${base_dir}/${new_name}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							# Rename the CSS file
 | 
				
			||||||
 | 
							mv "$css_file" "$new_path"
 | 
				
			||||||
 | 
							echo "Renamed: $css_file -> $new_path"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							# Update all HTML files under public recursively
 | 
				
			||||||
 | 
							find "$public_dir" -type f -name "*.html" | while read -r html_file; do
 | 
				
			||||||
 | 
								sed -i "s|$base_name$css_extension|$new_name|g" "$html_file"
 | 
				
			||||||
 | 
								echo "Updated references in: $html_file"
 | 
				
			||||||
 | 
							done
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Add timestamp to CSS files and update HTML references (including archiv/index.html)
 | 
					 | 
				
			||||||
update_css_references
 | 
					update_css_references
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user