|
55 | 55 | // source for the underlying version, like v1.0 or v1.1. |
56 | 56 | // Otherwise, the sidebar for a `stable` page would |
57 | 57 | // inappropriately link to the underlying `v1.0` page instead |
58 | | - // of the `stable` alias. |
59 | 58 | const pageVersion = (function () { |
60 | 59 | const pathComponents = location.pathname |
61 | 60 | .replace(sidebar.baseUrl, '') |
|
89 | 88 | // entry, if any, into the `.collapsed-header` element above. |
90 | 89 | function renderItems(items, paths) { |
91 | 90 | if (!items || items.length == 0) |
92 | | - return $(); |
| 91 | + return $(); |
93 | 92 |
|
94 | 93 | const lis = items.map(function (item) { |
95 | 94 | const urls = (item.urls || []).map(function (url) { |
|
103 | 102 | }); |
104 | 103 |
|
105 | 104 | // this ensures page will be highlighted in sidebar if URL is accessed with or without `.html` appended |
106 | | - var activePathname |
107 | | - if (!/^https?:/.test(location.pathname)) { |
108 | | - activePathname = location.pathname |
| 105 | + var activePathname = location.pathname; |
| 106 | + if (activePathname.includes("/index.html")) { |
| 107 | + activePathname = activePathname.replace("/index.html", "/"); |
109 | 108 | } |
110 | | - else { |
111 | | - activePathname = location.pathname |
| 109 | + if (activePathname.includes(".html")) { |
| 110 | + activePathname = activePathname.replace(".html", ""); |
112 | 111 | } |
113 | | - if (location.pathname.includes("/index.html")) { |
114 | | - activePathname = activePathname.replace("/index.html", "/") |
115 | | - } |
116 | | - if (location.pathname.includes(".html")) { |
117 | | - activePathname = activePathname.replace(".html", "") |
118 | | - } |
119 | | - // console.log(urls); |
120 | 112 |
|
121 | 113 | const active = (urls.indexOf(activePathname) !== -1); |
122 | 114 | if (active) { |
|
136 | 128 | .attr("href", urls[0] || "#") |
137 | 129 | .html(item.title); |
138 | 130 |
|
| 131 | + // ── **INJECT TAG BADGE HERE** ───────────────────────── |
| 132 | + if (item.tag) { |
| 133 | + a.append(" ") |
| 134 | + .append( |
| 135 | + $("<span>") |
| 136 | + .addClass("sidebar__tag sidebar__tag--new") |
| 137 | + .text(item.tag) |
| 138 | + ); |
| 139 | + } |
| 140 | + // ────────────────────────────────────────────────────── |
| 141 | + |
139 | 142 | if (subitems.length > 0 && !item.is_top_level) { |
140 | | - a.append(" ").append($("<div>").addClass("nav-expand")); |
| 143 | + a.append(" ").append($("<div>").addClass("nav-expand")); |
141 | 144 | } |
142 | 145 |
|
143 | 146 | return $("<li>") |
|
165 | 168 | // Version directories either are one of the named version |
166 | 169 | // aliases specified in _config.yml or have the form "vX.X", |
167 | 170 | // like "v1.0" or "v1.10". |
168 | | - return {{ site.versions | jsonify }}[d] || /^v\d+.\d+$/.test(d); |
| 171 | + return {{ site.versions | jsonify }}[d] || /^v\d+\.\d+$/.test(d); |
169 | 172 | }, |
170 | 173 | items: {%- include_cached {{ include.sidebar_data }} -%} |
171 | 174 | }; |
|
0 commit comments