diff --git a/bin/new-project b/bin/new-project index 8c8f647..e755790 100755 --- a/bin/new-project +++ b/bin/new-project @@ -338,6 +338,42 @@ setup_documentation() { log_success "Created documentation with symlink" } +update_sidebar() { + local name="$1" + local title="$2" + local sidebar_file="$PROJECT_DOCS_ROOT/sidebars.ts" + + log_step "Updating sidebars.ts" + + if [[ "$DRY_RUN" == true ]]; then + log_info "[DRY RUN] Would add '$title' to sidebar" + return 0 + fi + + # Check if already exists + if grep -q "projects/$name/overview" "$sidebar_file"; then + log_warn "Project already in sidebar" + return 0 + fi + + # Create the new sidebar entry + local sidebar_entry=" { + type: 'category', + label: '$title', + collapsed: true, + items: [ + 'projects/$name/overview', + 'projects/$name/updating-documentation', + ], + }," + + # Insert before "Goals & Roadmap" category + # Use perl for multi-line insertion (more reliable than sed) + perl -i -p0e "s|(\\s+\\{\\s+type: 'category',\\s+label: 'Goals & Roadmap',)|$sidebar_entry\n\$1|s" "$sidebar_file" + + log_success "Added project to sidebar" +} + update_build_script() { local name="$1" local title="$2" @@ -444,6 +480,7 @@ main() { create_local_project "$PROJECT_NAME" generate_project_files "$PROJECT_NAME" "$PROJECT_TITLE" "$PROJECT_TAGLINE" setup_documentation "$PROJECT_NAME" "$PROJECT_TITLE" "$PROJECT_TAGLINE" + update_sidebar "$PROJECT_NAME" "$PROJECT_TITLE" update_build_script "$PROJECT_NAME" "$PROJECT_TITLE" "$PROJECT_TAGLINE" initial_commit "$PROJECT_NAME"