Skip to content

Fix double slash issues in library page URL generation#1485

Merged
Alek99 merged 1 commit intomainfrom
devin/1752184543-fix-library-page-links
Jul 10, 2025
Merged

Fix double slash issues in library page URL generation#1485
Alek99 merged 1 commit intomainfrom
devin/1752184543-fix-library-page-links

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Jul 10, 2025

Fix double slash issues in library page URL generation

Summary

Fixed broken links throughout the library documentation page caused by double slashes in URLs (e.g., /docs/library//data-display instead of /docs/library/data-display). The issue occurred in URL construction logic when the prefix parameter was empty for core components, resulting in 404 errors when users clicked on component links.

Changes made:

  • Updated URL construction in library.py to conditionally include prefix only when non-empty
  • Fixed get_component_link function to handle empty prefix correctly
  • Updated category overview links to avoid double slashes
  • Fixed library preview page URL generation

Review & Testing Checklist for Human

  • Test core component links - Navigate to https://reflex.dev/docs/library/ and click on component links (e.g., Data Display, Forms, Layout) to verify they no longer have double slashes and load correctly
  • Test graphing component links - Verify graphing components still work with proper /graphing/ prefix (e.g., Charts, General, Other Charts sections)
  • Test sidebar navigation - Check that sidebar component links in the left navigation work correctly
  • Test component preview pages - Navigate to category pages and verify individual component links work
  • Verify URL patterns - Check that URLs follow expected patterns: /docs/library/{category}/ for core components and /docs/library/graphing/{category}/ for graphing components

Diagram

%%{ init : { "theme" : "default" }}%%
graph TB
    LibraryPage["pcweb/pages/docs/library.py<br/>Main library page"]:::major-edit
    ComponentLib["pcweb/components/docpage/sidebar/<br/>sidebar_items/component_lib.py<br/>URL generation logic"]:::major-edit
    LibraryPreviews["pcweb/pages/library_previews.py<br/>Component preview pages"]:::major-edit
    
    LibraryPage -->|"generates gallery links"| ComponentLib
    LibraryPreviews -->|"uses get_component_link"| ComponentLib
    ComponentLib -->|"creates URLs for"| CoreComponents["Core Components<br/>(no prefix)"]:::context
    ComponentLib -->|"creates URLs for"| GraphingComponents["Graphing Components<br/>(/graphing/ prefix)"]:::context
    
    subgraph Legend
        L1[Major Edit]:::major-edit
        L2[Minor Edit]:::minor-edit  
        L3[Context/No Edit]:::context
    end

    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB
    classDef context fill:#FFFFFF
Loading

Notes

  • Testing limitation: Could not test changes locally due to reflex-enterprise authentication requirements
  • Root cause: Empty prefix parameter for core components caused string concatenation like /docs/library/${empty_prefix}/${category} resulting in double slashes
  • Solution: Added conditional logic to only include prefix separator when prefix is non-empty
  • Session info: Link to Devin run: https://app.devin.ai/sessions/1db3909b76494994a02dc8e380ea7480, requested by @Alek99

Current broken state

- Fix URL construction in library.py to handle empty prefix correctly
- Fix get_component_link function to avoid double slashes when prefix is empty
- Fix category overview links to handle empty prefix properly
- Fix library preview page URL generation

This resolves 404 errors on library component links caused by URLs like /docs/library//data-display

Co-Authored-By: Alek <alek@pynecone.io>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Fixed URL path generation across the component library system to prevent double slashes and ensure consistent routing behavior.

  • Modified pcweb/components/docpage/sidebar/sidebar_items/component_lib.py to improve prefix path handling in get_component_link and get_category_children
  • Updated pcweb/pages/docs/library.py to properly construct href attributes with conditional trailing slashes
  • Fixed URL generation in pcweb/pages/library_previews.py by adding trailing slashes only when prefixes exist

3 files reviewed, no comments
Edit PR Review Bot Settings | Greptile

@Alek99 Alek99 merged commit f775e24 into main Jul 10, 2025
9 checks passed
@Alek99 Alek99 deleted the devin/1752184543-fix-library-page-links branch July 10, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants