diff --git a/config/filters/index.js b/config/filters/index.js index 573ebd91..4793cd39 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -37,6 +37,12 @@ export default { }, replaceQuotes: (string) => string.replace(/"/g, "'"), + // navigation + isLinkActive: (category, page) => { + const normalizedPage = page.includes('.html') ? page.replace('.html', '/') : page + return !!normalizedPage && normalizedPage.includes(category) && !/\d+/.test(normalizedPage); + }, + // analytics getPopularPosts: (posts, analytics) => { return posts diff --git a/package.json b/package.json index 48967d6b..630066ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "8.1.4", + "version": "8.2.4", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": { diff --git a/src/_includes/partials/nav/link.liquid b/src/_includes/partials/nav/link.liquid index 955592b6..148274e1 100644 --- a/src/_includes/partials/nav/link.liquid +++ b/src/_includes/partials/nav/link.liquid @@ -1,5 +1,5 @@ -{%- capture pageUrl %}/{{ link | downcase }}/{% endcapture -%} -{% if pageUrl contains page.fileSlug and page.fileSlug %} +{%- capture categoryUrl %}/{{ link | downcase }}/{% endcapture -%} +{% if categoryUrl | isLinkActive: page.url %} {% if icon %} {% tablericon icon link %}