1+ #! /bin/bash
2+
3+ # Script to update cross-reference link text
4+ # To run: 'bash scripts/update_docs_links.sh' from the root of the replicated-docs repository
5+ # Run this script after changing the title of one or more pages in the docs directory
6+
7+ # Define replacement patterns with the format "[search pattern]:[replacement]"
8+ patterns=(
9+ # "Adding Nodes to kURL Clusters:Add Nodes to kURL Clusters"
10+ )
11+
12+ # # Count of files processed and replacements made
13+ # files_processed=0
14+ # replacements_made=0
15+
16+ echo " Searching in the /docs directory and updating cross-references..."
17+
18+ # Process each file in the docs directory
19+ # Exclude .history
20+ find docs -type f -name " *.md*" -not -path " */\.history/*" | while read file; do
21+ file_modified=false
22+
23+ # Process each replacement pair
24+ for pattern_pair in " ${patterns[@]} " ; do
25+ # Split the pattern_pair into search and replacement parts
26+ IFS=' :' read -r search replacement <<< " $pattern_pair"
27+
28+ # Check if file contains the pattern
29+ if grep -q " see \[${search} \]" " $file " || grep -q " See \[${search} \]" " $file " ; then
30+ # Make the replacements
31+ sed -i ' ' " s/see \[${search} \]/see \[${replacement} \]/g" " $file "
32+ sed -i ' ' " s/See \[${search} \]/See \[${replacement} \]/g" " $file "
33+
34+ echo " In $file :"
35+ echo " Replaced: '$search ' → '$replacement '"
36+
37+ file_modified=true
38+ (( replacements_made++ ))
39+ fi
40+ done
41+
42+ if $file_modified ; then
43+ (( files_processed++ ))
44+ fi
45+ done
46+
47+ echo " Done!"
48+ # echo "Files processed: $files_processed"
49+ # echo "Total replacements made: $replacements_made"
50+ # Instructions for verifying changes
51+ echo " Next steps:"
52+ echo " 1. Review the changes using 'git diff'"
53+ echo " 2. Run 'npm run build' to check for broken links"
54+ echo " 3. Commit the changes if everything looks good"
0 commit comments