You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by er...@apache.org on 2026/02/18 07:41:16 UTC
(cordova-docs) branch master updated: fix(toc): highlight toc entries pointing to index.html (#1471)
This is an automated email from the ASF dual-hosted git repository.
erisu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-docs.git
The following commit(s) were added to refs/heads/master by this push:
new 20c20fd858 fix(toc): highlight toc entries pointing to index.html (#1471)
20c20fd858 is described below
commit 20c20fd8584e3863a91ffb7283c0a300aa619daa
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Wed Feb 18 08:41:11 2026 +0100
fix(toc): highlight toc entries pointing to index.html (#1471)
* fix(toc): highlight toc entries without sub-entries
- Fix an issue where menu entries weren't being highlighted or scrolled to when navigating between documentation pages, particularly affecting nested entries without children (e.g., "Security" under "Security & Privacy").
- Normalize URLs to handle Jekyll's pretty URLs (e.g., "path/") vs TOC entry URLs (e.g., "path/index.html") for proper comparison
- Add validation to prevent false matches on pages without URLs
- Fixes: https://github.com/apache/cordova-docs/issues/1417
Generated-By: Claude Sonnet 4.5
* Remove redundant `index.html` replace
- It's enough to just replace `index.html` with an empty string
* Add normalization for toc dropdown
- This is used on mobile devices. Since the css is not properly configured for the dropdown the highlighting cannot be seen
---
www/_includes/toc_recursive_dropdown.html | 12 +++++++++++-
www/_includes/toc_recursive_main.html | 15 ++++++++++++---
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/www/_includes/toc_recursive_dropdown.html b/www/_includes/toc_recursive_dropdown.html
index f78ea8f701..60327419e1 100644
--- a/www/_includes/toc_recursive_dropdown.html
+++ b/www/_includes/toc_recursive_dropdown.html
@@ -1,7 +1,17 @@
{% for entry in include.entries %}
+
+{% comment %}Normalize URLs for comparison: my_entry may be "path/" while entry.url is "path/index.html"{% endcomment %}
+{% assign normalized_entry_url = entry.url | replace: "index.html", "" %}
+{% assign is_current_page = false %}
+{% if entry.url and entry.url != "" and include.my_entry and include.my_entry != "" %}
+ {% if include.my_entry == entry.url or include.my_entry == normalized_entry_url %}
+ {% assign is_current_page = true %}
+ {% endif %}
+{% endif %}
+
{% if entry.url != null %}
<li>
- <a class="{% if include.my_entry == entry.url %}this-page{% endif %}" href="{{ include.path_to_root }}{{ entry.url }}">
+ <a class="{% if is_current_page %}this-page{% endif %}" href="{{ include.path_to_root }}{{ entry.url }}">
{{ entry.name }}
</a>
</li>
diff --git a/www/_includes/toc_recursive_main.html b/www/_includes/toc_recursive_main.html
index b42d50dcef..2fe5c6c757 100644
--- a/www/_includes/toc_recursive_main.html
+++ b/www/_includes/toc_recursive_main.html
@@ -1,16 +1,25 @@
<ul class="site-toc">
{% for entry in include.entries %}
+ {% comment %}Normalize URLs for comparison: my_entry may be "path/" while entry.url is "path/index.html"{% endcomment %}
+ {% assign normalized_entry_url = entry.url | replace: "index.html", "" %}
+ {% assign is_current_page = false %}
+ {% if entry.url and entry.url != "" and include.my_entry and include.my_entry != "" %}
+ {% if include.my_entry == entry.url or include.my_entry == normalized_entry_url %}
+ {% assign is_current_page = true %}
+ {% endif %}
+ {% endif %}
+
<li>
{% if entry.children %}
<span class="toc-section-heading">
{{ entry.name }}
</span>
{% else %}
- <a class="{% if include.my_entry == entry.url %}this-page{% endif %}" href="{{ include.path_to_root }}{{ entry.url }}">
+ <a class="{% if is_current_page %}this-page{% endif %}" href="{{ include.path_to_root }}{{ entry.url }}">
{{ entry.name }}
</a>
- {% if include.my_entry == entry.url %}
+ {% if is_current_page %}
<span class="entry-highlight"></span>
{% endif %}
{% endif %}
@@ -18,7 +27,7 @@
{% comment %}
Insert page-specific ToC here if this is the entry for this page
{% endcomment %}
- {% if include.my_entry == entry.url %}<div id="page-toc" class="page-toc"></div>{% endif %}
+ {% if is_current_page %}<div id="page-toc" class="page-toc"></div>{% endif %}
{% if entry.children %}
{% include toc_recursive_main.html entries=entry.children my_entry=include.my_entry path_to_root=include.path_to_root %}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org