Fix issues with rendering breacrumbs and blog nav outside main site

This commit is contained in:
Helen Chong 2024-04-19 20:04:25 +08:00
parent ca4ecd2cee
commit 5ade6af6b0
1 changed files with 17 additions and 10 deletions

View File

@ -1,14 +1,16 @@
<header class="main__header"> <header class="main__header">
{% if isArticle %} {% if isArticle %}
<ul class="breadcrumbs"> {% if eleventyNavigation %}
{% set breadcrumbNavPages = collections.all | eleventyNavigationBreadcrumb(articleTitle) %} <ul class="breadcrumbs">
{%- for entry in breadcrumbNavPages %} {% set breadcrumbNavPages = collections.all | eleventyNavigationBreadcrumb(articleTitle) %}
<li> {%- for entry in breadcrumbNavPages %}
<a href="{{ entry.url }}" {% if entry.url == page.url %} class="breadcrumbs--active"{% endif %}>{{ entry.title }}</a> <li>
</li> <a href="{{ entry.url }}" {% if entry.url == page.url %} class="breadcrumbs--active"{% endif %}>{{ entry.title }}</a>
</li>
{%- endfor %}
</ul> {%- endfor %}
</ul>
{% endif %}
<h1>{{ articleTitle }}</h1> <h1>{{ articleTitle }}</h1>
<div class="article__info"> <div class="article__info">
@ -48,7 +50,12 @@
</div> </div>
{% endif %} {% endif %}
{% if tags and tags.includes("contents") or page.url === "/articles/" or tags and tags.includes("blog pages") %} {% if
tags and tags.includes("articles")
or tags and tags.includes("posts")
or page.url === "/articles/"
or tags and tags.includes("blog pages")
%}
{% include "main/content-nav.njk" %} {% include "main/content-nav.njk" %}
{% endif %} {% endif %}