Skip to content

Commit

Permalink
// -> /
Browse files Browse the repository at this point in the history
  • Loading branch information
gllmAR committed Sep 9, 2024
1 parent 60fcba1 commit 439fe1a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
31 changes: 22 additions & 9 deletions .run/20_generate_subnav.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

EXCLUDED_DIRS=(".git" "node_modules" "__pycache__" ".vscode")

# Get the current working directory (root of the project)
ROOT_DIR=$(pwd)

# Function to extract the title from README.md
get_title_from_readme() {
local readme_path="$1"
Expand Down Expand Up @@ -39,20 +42,30 @@ generate_readme_in_subfolders() {
local subdir_readme="$subdir/README.md"
local subdir_title

# Only generate a link if the subdirectory contains a README.md
if [[ -f "$subdir_readme" ]]; then
subdir_title=$(get_title_from_readme "$subdir_readme")
fi

if [[ -z "$subdir_title" ]]; then
subdir_title="$base_dir"
fi
if [[ -z "$subdir_title" ]]; then
subdir_title="$base_dir"
fi

# Remove trailing slash from parent_dir if it exists, then construct the path
local clean_parent_dir="${parent_dir%/}"
local absolute_path="$clean_parent_dir/$base_dir/README.md"
# Clean up paths to avoid double slashes
local clean_parent_dir="${parent_dir%/}"
local clean_base_dir="${base_dir%/}"

new_content+="* [$subdir_title](/$absolute_path)\n"
echo "Generated link for /$absolute_path with title '$subdir_title'"
# Combine paths and ensure no double slashes
local absolute_path="$clean_parent_dir/$clean_base_dir/README.md"
absolute_path="/${absolute_path#"$ROOT_DIR/"}" # Remove root directory and ensure no leading //

# Replace any instances of double slashes (except the leading slash)
absolute_path=$(echo "$absolute_path" | sed 's|//|/|g')

new_content+="* [$subdir_title]($absolute_path)\n"
echo "Generated link for $absolute_path with title '$subdir_title'"
else
echo "Skipped directory (no README.md): $subdir"
fi
fi
done

Expand Down
4 changes: 2 additions & 2 deletions contenus/github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

<!-- generateSubNav -->

* [Publication de Pages GitHub](/contenus//github/pages/README.md)
* [Intégration Continue](/contenus//github/scriptCI/README.md)
* [Publication de Pages GitHub](/contenus/github/pages/README.md)
* [Intégration Continue](/contenus/github/scriptCI/README.md)

0 comments on commit 439fe1a

Please sign in to comment.