Skip to content

Commit

Permalink
updated shell script to use right layout
Browse files Browse the repository at this point in the history
  • Loading branch information
CameronBrooks11 committed Jan 14, 2025
1 parent db1cd14 commit fc07593
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions sync_docs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
#!/bin/bash

# Ensure the submodules are updated
git submodule update --remote --merge
# Set layout type for README.md files (can be easily changed)
LAYOUT_TYPE="page"

# Force submodule update (set to true to force changes)
FORCE_SUBMODULE_UPDATE=true

# If FORCE_SUBMODULE_UPDATE is true, reinitialize and update submodules
if [ "$FORCE_SUBMODULE_UPDATE" = true ]; then
echo "Forcing submodule update..."
git submodule update --init --recursive --force
else
echo "Normal submodule update..."
git submodule update --remote --merge
fi

# Loop through each project in the _projects folder
for project in _projects/*; do
Expand All @@ -15,21 +27,21 @@ for project in _projects/*; do
if [ -f "$project/README.md" ]; then
readme_file="$project/README.md"
readme_title=$(basename "$project" | sed -e 's/-/ /g' -e 's/\b\(.\)/\u\1/g')

# Check if front matter exists in the README
if ! grep -q "^---" "$readme_file"; then
# Add front matter with a proper permalink and title
echo -e "---\nlayout: project-index\ntitle: \"$readme_title\"\npermalink: /projects/$(basename "$project")/\n---\n$(cat "$readme_file")" > "$readme_file"
# Add front matter with the proper permalink, title, and layout type
echo -e "---\nlayout: $LAYOUT_TYPE\ntitle: \"$readme_title\"\npermalink: /projects/$(basename "$project")/\n---\n$(cat "$readme_file")" > "$readme_file"
fi
fi

# Process each markdown file in docs
find "$project/docs" -name "*.md" | while read -r file; do
# Extract relative path from the docs folder and generate a URL-friendly title
relative_path=${file#"$project/docs/"}
filename=$(basename "$relative_path" .md)
title=$(echo "$filename" | sed -e 's/-/ /g' -e 's/\b\(.\)/\u\1/g')

# Check if front matter exists
if ! grep -q "^---" "$file"; then
# Add front matter with a proper permalink and title
Expand Down

0 comments on commit fc07593

Please sign in to comment.