Skip to content

if uglyurls = true , the $active is not as expected #9

@anbang

Description

@anbang

set uglyurls = true in /config/_default/config.toml
file : /themes/zzodoc/layouts/partials/main/sections/list-menu.html
code :

  {{ $root := .root }}
  {{ $ctx := .ctx }}
  {{ $depth := .depth }}
  <!-- Before: http://localhost:1313/zdoc/gettingstarted/quickstart/ -->
  <!-- Now   : http://localhost:1313/zdoc/gettingstarted/quickstart.html -->
  {{ $currentURL := $root.Permalink }}
  {{ $sectionName1 := index (last 1 (split (delimit (split $ctx.Permalink "/") "," "") ",")) 0 }}
  {{ $sectionName2 := index (last 2 (split (delimit (split $currentURL "/") "," "") ",")) 0 }}
  <!-- $active -->
  {{ $active := in $currentURL $ctx.Permalink }}
  {{ $active = or $active (eq $sectionName1 $sectionName2) }}
  {{ $active = or $active (in $currentURL $sectionName1) }}

EDIT THIS PAGE also has this problem. Can you help? thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions