Set a custom front matter variable "slug" in top of your post.blade.md
file which is the same as the filename, here: this-post-example.blade.md
---
extends: _layouts.post
section: content
title: This Post Example
slug: this-post-example
---
In config.php
:
<?php
use Illuminate\Support\Str;
return [
'isActive' => function ($page, $path) {
return Str::endsWith(trimPath($page->getPath()), trimPath($path));
},
];
In source/_partials/nav.blade.php
:
<nav class="nav" id="nav">
<ul class="nav_list" id="navList">
<li><a href="{{ $page->baseUrl }}/">home</a></li>
@foreach ($posts as $post)
<li><a href="{{ $post->getUrl() }}" class="nav_list_link @if ($post->slug === $page->getFilename()) active @endif">{{ $post->title }}</a></li>
@endforeach
</ul>
</nav>