@@ -201,7 +201,7 @@ cat > index.html << 'EOF'
201201EOF
202202
203203# Find all HTML files except index.html and add them to the page
204- html_files=$( find . -maxdepth 1 - name " *.html" ! -name " index.html" | sort)
204+ html_files=$( find . -name " *.html" ! -name " index.html" | sort)
205205
206206if [ -z " $html_files " ]; then
207207 cat >> index.html << 'EOF '
@@ -213,22 +213,24 @@ if [ -z "$html_files" ]; then
213213EOF
214214else
215215 for file in $html_files ; do
216+ # Remove leading ./ from path
217+ relative_path=" ${file# ./ } "
216218 filename=$( basename " $file " )
217- # URL encode the filename for use in href attributes
219+ # URL encode the path for use in href attributes
218220 # This handles special characters like spaces, %, etc.
219- encoded_filename =$( printf ' %s' " $filename " | jq -sRr @uri)
221+ encoded_path =$( printf ' %s' " $relative_path " | jq -sRr @uri)
220222 # Convert filename to readable title (remove .html, replace hyphens/underscores with spaces, capitalize)
221223 # Also decode any URL-encoded characters for the display title
222224 decoded_filename=$( printf ' %s' " $filename " | sed ' s/%20/ /g' | sed ' s/%/ /g' )
223225 title=$( echo " $decoded_filename " | sed ' s/.html$//' | sed ' s/[-_]/ /g' | awk ' {for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1' )
224226
225227 cat >> index.html << EOF
226228 <div class="chart-card">
227- <a href="$encoded_filename ">$title </a>
228- <div class="chart-name">$filename </div>
229+ <a href="$encoded_path ">$title </a>
230+ <div class="chart-name">$relative_path </div>
229231 <div class="button-group">
230- <a href="$encoded_filename " class="btn btn-primary">View Chart</a>
231- <button class="btn btn-secondary" onclick="copyEmbedCode('$encoded_filename ')">Copy Embed Code</button>
232+ <a href="$encoded_path " class="btn btn-primary">View Chart</a>
233+ <button class="btn btn-secondary" onclick="copyEmbedCode('$encoded_path ')">Copy Embed Code</button>
232234 </div>
233235 </div>
234236EOF
0 commit comments