Skip to content

Commit

Permalink
doc: fix active page formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gotbadger committed Dec 15, 2023
1 parent bc82618 commit 0fe1116
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
12 changes: 2 additions & 10 deletions docs/.eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,8 @@ module.exports = function (eleventyConfig) {
}
})

eleventyConfig.addNunjucksGlobal("navHighlight", (parent, child) => {
const target = parent.split(path.sep).slice(1, -1)
const check = child.split(path.sep).slice(1, -1)
// handles individual rule pages highlighting "rule" in side nav
const isRule = target.includes("rules")
if (child === parent || isRule) {
return true
} else {
return false
}
eleventyConfig.addNunjucksGlobal("navHighlight", (item_url, current_url) => {
return current_url.startsWith(item_url)
})

eleventyConfig.addPairedShortcode(
Expand Down
8 changes: 7 additions & 1 deletion docs/_src/_includes/layouts/doc.njk
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ layout: layouts/base.njk
<ul class="ml-2">
{% for item in heading.items %}
<li>
<a class="hover:underline block" {% if navHighlight(item.url, page.url) %}aria-current="page" {% endif %} href="{{item.url}}">{{item.name}}</a>
<a
class="hover:underline block"
{% if navHighlight(item.url, page.url) %}aria-current="page" {% endif %}
href="{{item.url}}"
>
{{item.name}}
</a>
</li>
{% endfor %}
</ul>
Expand Down

0 comments on commit 0fe1116

Please sign in to comment.