fix(layouts): fix variable name from $name to $dirName in currentMenuItem.html partial to improve semantics and clarity

This commit is contained in:
Sped0n
2023-11-03 09:51:44 +08:00
parent eb6c485ea5
commit 5c69862832
3 changed files with 5 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
{{- $params := .Scratch.Get "params" -}}
{{- $currentPage := . -}}
{{- with partial "function/currentMenuItem.html" . -}}
{{- partial "resources/imageJSON.html" (dict "Path" .Name "Page" $currentPage) -}}
{{- partial "resources/imageJSON.html" (dict "Path" .DirName "Page" $currentPage) -}}
<script>document.getElementById("main").setAttribute("currentMenuItemIndex", "{{- (sub .ID 1) -}}")</script>
{{- end -}}
<div class="container">

View File

@@ -2,7 +2,7 @@
{{- $params := .Scratch.Get "params" -}}
{{- $currentPage := . -}}
{{- with partial "function/currentMenuItem.html" . -}}
{{- partial "resources/imageJSON.html" (dict "Path" .Name "Page" $currentPage) -}}
{{- partial "resources/imageJSON.html" (dict "Path" .DirName "Page" $currentPage) -}}
<script>document.getElementById("main").setAttribute("currentMenuItemIndex", "{{- (sub .ID 1) -}}")</script>
{{- end -}}
<div class="container">

View File

@@ -1,15 +1,15 @@
{{- $currentPage := . -}}
{{- $name := "" -}}
{{- $dirName := "" -}}
{{- $id := -1 -}}
{{- range site.Menus.main -}}
{{ $menu_item_url := .URL | relLangURL }}
{{ $page_url:= $currentPage.RelPermalink | relLangURL }}
{{ if eq $menu_item_url $page_url }}
{{- $name = .Identifier -}}
{{- $dirName = .Identifier -}}
{{- $id = .Weight -}}
{{- end -}}
{{- end -}}
{{- return (dict "Name" $name "ID" $id) -}}
{{- return (dict "DirName" $dirName "ID" $id) -}}