You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "dheeraj12347 (via GitHub)" <gi...@apache.org> on 2026/01/16 11:20:10 UTC

[PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

dheeraj12347 opened a new pull request, #1463:
URL: https://github.com/apache/cordova-docs/pull/1463

   ## Problem
   Table of Contents (TOC) highlighting is not working correctly for some pages.
   
   ## Root Cause
   The URL comparison logic in `toc_recursive_main.html` and `toc_recursive_dropdown.html` was failing due to trailing slash differences between `include.my_entry` and `entry.url`.
   
   Example:
   - include.my_entry: `/docs/api/`
   - entry.url: `/docs/api`
   
   These look the same but don't match as strings.
   
   ## Solution
   Normalize both URLs before comparison by removing trailing slashes using Jekyll's `remove` filter.
   
   Added:
   ```liquid
   {% assign normalized_my_entry = include.my_entry | remove: '/' %}
   {% assign normalized_entry_url = entry.url | remove: '/' %}
   ## Solution
   Normalize both URLs before comparison by removing trailing slashes using Jekyll's `remove` filter.
   
   Added:
   ```liquid
   {% assign normalized_my_entry = include.my_entry | remove: '/' %}
   {% assign normalized_entry_url = entry.url | remove: '/' %}
   Then compare:
   
   text
   {% if normalized_my_entry == normalized_entry_url %}
   Files Changed
   www/_includes/toc_recursive_main.html
   
   www/_includes/toc_recursive_dropdown.html
   
   Why This Works
   Removes all / characters from both URLs before comparison
   
   Makes the comparison consistent regardless of trailing slashes
   
   Current page highlighting now works correctly
   
   No JavaScript changes needed
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "breautek (via GitHub)" <gi...@apache.org>.
breautek commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3861468939

   I apologize in advance if I'm wrong but the responses appears AI-ish, which begs me to question if the PR is also written by AI.
   
   If an AI tool is being used it will need to be disclosed. [Apache](https://www.apache.org/legal/generative-tooling.html#include-in-contributions) does allow AI tooling to be used for contributions, but there should be a disclaimer maybe in the original PR description and perhaps in the commit message if it was generated by a particular AI tool. We also have to ensure that the tool does not place any restrictions on the use of the generated content.
   
   Are you able to confirm if AI was used to create this PR, and if so can you add a disclaimer?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3871468322

   Can you try another approach?
   
   We can normalize `my_entry` before it enters `toc_recursive_main.html` and `toc_recursive_dropdown.html`.
   
   `my_entry` is given to the includes in [_layouts/docs.html](https://github.com/apache/cordova-docs/blob/master/www/_layouts/docs.html). On line 18 `MY_ENTRY` is set: https://github.com/apache/cordova-docs/blob/7f2a7dc34b42644626b7e83db96238d3094d9af6/www/_layouts/docs.html#L18
   
   Her you can add:
   
   ```liquid
   {% if MY_ENTRY | slice: -1 == "/" %}
       {% assign MY_ENTRY = MY_ENTRY | slice: 0, MY_ENTRY.size | minus: 1 %}
   {% endif %}
   ```
   
   This will remove a trailing slash for `my_entry`. You can remove the changes you made in `toc_recursive_main.html` and `toc_recursive_dropdown.html`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "dheeraj12347 (via GitHub)" <gi...@apache.org>.
dheeraj12347 commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3870481506

   Hi @breautek, thanks for the heads-up! I want to be clear: this PR wasn't "written" by AI. I did the local debugging and developed the logic myself. However, I did use Gemini as a sounding board to refine the Liquid syntax and to help me structure my comments so they were clear and professional.
   
   I wasn't aware of the specific Apache disclosure policy, but I'm happy to follow it. I'll go ahead and add the Generated-by: Gemini tag to my commit messages now to stay transparent. Thanks for the guidance!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "dheeraj12347 (via GitHub)" <gi...@apache.org>.
dheeraj12347 commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3870566215

   I've updated the commit message with the Generated-by: Gemini tag and force-pushed the changes. I also double-checked the logic locally to ensure it only handles the trailing slashes and doesn't affect the rest of the URL structure. Ready for another review! @breautek @erisu


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "dheeraj12347 (via GitHub)" <gi...@apache.org>.
dheeraj12347 commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3762780538

   @GitToTheHub Thank you for the review! I've updated both files to use the cleaner single-line comparison as you suggested:
   
   Changed from:
   {% assign normalized_my_entry = include.my_entry | remove: '/' %}
   {% assign normalized_entry_url = entry.url | remove: '/' %}
   {% if normalized_my_entry == normalized_entry_url %}
   
   To:
   {% assign entry_active = include.my_entry | remove: '/' == entry.url | remove: '/' %}
   {% if entry_active %}
   
   This is much cleaner and more readable. Changes have been pushed. Thanks for the improvement suggestion!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub closed pull request #1463: fix: normalize URL comparison in TOC highlighting
URL: https://github.com/apache/cordova-docs/pull/1463


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "dheeraj12347 (via GitHub)" <gi...@apache.org>.
dheeraj12347 commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3776130884

   Thanks for the detailed reviews and for testing the menu behavior locally.
   
   You were right that using remove: '/' removed all slashes, not just a trailing one, and that it could cause the menu/highlighting issues you described. I’ve updated both www/_includes/toc_recursive_main.html and www/_includes/toc_recursive_dropdown.html so that entry_active compares include.my_entry and entry.url after only normalizing a possible trailing /, while leaving intermediate path segments unchanged.
   
   After a clean local rebuild, the TOC no longer appears duplicated/flattened, and only the correct entry is highlighted on the pages I tested. Please let me know if this approach looks good to you or if you’d prefer any further adjustments.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "erisu (via GitHub)" <gi...@apache.org>.
erisu commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3774334174

   Locally, the menu does not appear to be functioning as expected. Some elements seem duplicated, and the overall layout appears inconsistent.
   
   For example, the top set of links appears flattened and is not interactive. The lower section, which seems to mirror the top with some formatting and contain navigational links; however, all items are highlighted simultaneously.
   
   I am also not certain whether removing the “/” is the correct solution. Based on my testing, it does not remove only the trailing slash as described in the PR description, but instead removes all slashes.
   
   I also tried clearing previous builds, rebuilding from scratch, and clearing the cache to confirm that this is not an issue on my end.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on code in PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#discussion_r2698745171


##########
www/_includes/toc_recursive_dropdown.html:
##########
@@ -1,7 +1,10 @@
 {% for entry in include.entries %}
+{% assign normalized_my_entry = include.my_entry | remove: '/' %}
+{% assign normalized_entry_url = entry.url | remove: '/' %}

Review Comment:
   Since this is used only to determine if the entry should be highlighted, you could make a variable like
   
   ```liquid
   {% assign entry_active = include.my_entry | remove: '/' == entry.url | remove: '/' %}
   ```
   
   and use it for highlighting.



##########
www/_includes/toc_recursive_main.html:
##########
@@ -1,24 +1,29 @@
 <ul class="site-toc">
     {% for entry in include.entries %}
 
+    {% assign normalized_my_entry = include.my_entry | remove: '/' %}
+    {% assign normalized_entry_url = entry.url | remove: '/' %}

Review Comment:
   Since this is used only to determine if the entry should be highlighted, you could make a variable like
   
   ```liquid
   {% assign entry_active = include.my_entry | remove: '/' == entry.url | remove: '/' %}
   ```
   
   and use it for highlighting.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3765705913

   Very good :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3872010434

   Hi, I created an PR to fix the highlighting in #1471 
   
   It was because of the comparison of Jekyll's pretty URLs (e.g., "path/") vs TOC entry URLs (e.g., "path/index.html").


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3765706238

   @erisu Is this fine to merge?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [PR] fix: normalize URL comparison in TOC highlighting [cordova-docs]

Posted by "GitToTheHub (via GitHub)" <gi...@apache.org>.
GitToTheHub commented on PR #1463:
URL: https://github.com/apache/cordova-docs/pull/1463#issuecomment-3774917330

   Thanks for verifying this, so @dheeraj12347 checked it not correctly?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org