Koa-router in koa adds styles when clicked like this.

such a navigation clipboard.png
jumps through koarouter, but when you jump like this, give him a style or class name

router.get("/contantus", async ctx => {
  console.log(ctx.response)
  await ctx.render("contantus", {title: ""})
})

router.get("/products", async ctx => {
  await ctx.render("products", {title: ""})
})
HMTL


 <ul class="nav-list">
      <li></li>
      <li class={{active}}><a href="/products"></a> </li>
      <li></li>
      <li><a href="/contantus"></a> </li>
    </ul>
    
    
    
    koa-nunjucks-2 active
    
Sep.03,2021
The owner of

can solve the problem differently. It can be matched according to the current url address. If the current url is products , then add active to the li of the product. There is no need for koa-router to do anything.

Menu