Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(modern-template): respect url normalization for toc #9036

Closed
wants to merge 3 commits into from

Conversation

Lulalaby
Copy link
Contributor

@Lulalaby Lulalaby commented Aug 2, 2023

The current problem

If you have something like .htaccess url rewrite active, the toc expansion does not work.
Example rewrite:

RewriteEngine On
RewriteBase /


RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R=301,L]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

Screenshots

without url rewrite
with url rewrite

Proposed Solution

By adding a config option called _urlNormalizationActive and parsing this in the toc.ts of the modern template as docfx:urlnormalizationactive, we can achieve the toc expansion.

Screenshots

working with url rewrite

@codecov
Copy link

codecov bot commented Aug 2, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01% ⚠️

Comparison is base (62876b4) 77.56% compared to head (89dec26) 77.56%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9036      +/-   ##
==========================================
- Coverage   77.56%   77.56%   -0.01%     
==========================================
  Files         591      591              
  Lines       24577    24577              
==========================================
- Hits        19064    19063       -1     
- Misses       5513     5514       +1     

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Lulalaby Lulalaby changed the title feat(modern-template): respect url rewrites for toc feat(modern-template): respect url normalization for toc Aug 2, 2023
@Lulalaby Lulalaby force-pushed the main branch 2 times, most recently from 7d49d8f to adb5614 Compare August 3, 2023 12:28
Copy link
Contributor

@yufeih yufeih left a comment

Choose a reason for hiding this comment

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

This fix feels a bit hacky. Would #2865 address your scenario once it lands?

@Lulalaby
Copy link
Contributor Author

Lulalaby commented Aug 7, 2023

Yeah that's basically what i mean, we should keep in mind for that issue tho, that it needs to work seamless with existing environments if needed.
I agree that this pr is hacky, I'm gonna close it for now.

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