From 03f3500c3547e9190fcf16df511d4b29b56d9c6a Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Thu, 15 Jan 2026 15:32:34 +0800 Subject: [PATCH] fix(file-tree): improve item sorting logic // ignore-for-release --- layouts/_partials/init/index.html | 2 +- layouts/_partials/plugin/file-tree.html | 42 ++++++++++++++++++------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/layouts/_partials/init/index.html b/layouts/_partials/init/index.html index a9ad7a81..15c484a5 100644 --- a/layouts/_partials/init/index.html +++ b/layouts/_partials/init/index.html @@ -1,4 +1,4 @@ -{{- hugo.Store.Set "version" "v0.4.2-20260114101213-fdfd7721" -}} +{{- hugo.Store.Set "version" "v0.4.2-20260115073234-b4008081" -}} {{- .Store.Set "this" dict -}} {{- partial "init/detection-env.html" . -}} diff --git a/layouts/_partials/plugin/file-tree.html b/layouts/_partials/plugin/file-tree.html index 1af9ef8d..f4d1ea4c 100644 --- a/layouts/_partials/plugin/file-tree.html +++ b/layouts/_partials/plugin/file-tree.html @@ -1,11 +1,11 @@ {{- /* Recursive function to render tree from structured data @param {array} items - Array of tree items - @param {int} depth - Current depth level @param {int} level - The expand level of the tree (expand all: -1, collapse all: 0) - @param {bool} folderSlash - Whether to append a trailing "/" to folder names - @param {array} ignoreList - List of file or folder names to ignore - @param {array} highlightList - List of file or folder names to highlight + @param {int} [depth=0] - Current depth level + @param {bool} [folderSlash=false] - Whether to append a trailing "/" to folder names + @param {array} [ignoreList] - List of file or folder names to ignore + @param {array} [highlightList] - List of file or folder names to highlight File tree item structure: name: string - The name of the file or folder @@ -14,17 +14,28 @@ */ -}} {{- define "render-file-tree" -}} {{- $items := .items -}} - {{- $depth := .depth -}} {{- $level := .level -}} - {{- $folderSlash := .folderSlash -}} + {{- $depth := .depth | default 0 -}} + {{- $folderSlash := .folderSlash | default false -}} {{- $ignoreList := .ignoreList | default slice -}} - {{- $highlightList := .highlightList -}} + {{- $highlightList := .highlightList | default slice -}}