fix(header.liquid): set header link active state properly
This commit is contained in:
parent
d13984f114
commit
0c64cdf570
4 changed files with 15 additions and 6 deletions
|
@ -1,4 +1,12 @@
|
||||||
|
const normalizeUrl = (url) =>
|
||||||
|
url.replace(/index\.php$|index\.html$/i, '').replace(/\.php$|\.html$/i, '') || '/';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
isLinkActive: (category, page) =>
|
isLinkActive: (category, page) => {
|
||||||
page.includes(category) && page.split('/').filter((a) => a !== '').length <= 1
|
const normalized = normalizeUrl(page);
|
||||||
|
return (
|
||||||
|
normalized.includes(category) && normalized.split('/').filter((a) => a !== '').length <= 1
|
||||||
|
);
|
||||||
|
},
|
||||||
|
normalizeUrl
|
||||||
};
|
};
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "10.6.4",
|
"version": "10.6.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "10.6.4",
|
"version": "10.6.5",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"minisearch": "^7.1.2",
|
"minisearch": "^7.1.2",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coryd.dev",
|
"name": "coryd.dev",
|
||||||
"version": "10.6.4",
|
"version": "10.6.5",
|
||||||
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
"description": "The source for my personal site. Built using 11ty (and other tools).",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{%- assign normalizedUrl = page.url | normalizeUrl -%}
|
||||||
{%- capture headerContent -%}
|
{%- capture headerContent -%}
|
||||||
<img
|
<img
|
||||||
srcset="
|
srcset="
|
||||||
|
@ -14,7 +15,7 @@
|
||||||
{%- endcapture -%}
|
{%- endcapture -%}
|
||||||
<section class="main-title">
|
<section class="main-title">
|
||||||
<h1>
|
<h1>
|
||||||
{%- if page.url == "/" -%}
|
{%- if normalizedUrl == "/" -%}
|
||||||
{{ headerContent }}
|
{{ headerContent }}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
<a href="/" tabindex="0">{{ headerContent }}</a>
|
<a href="/" tabindex="0">{{ headerContent }}</a>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue