mirror of
https://github.com/hugo-fixit/FixIt.git
synced 2026-08-24 15:28:57 +00:00
feat(file-tree): enhance shortcode with name param and deprecated fullRootName param
// ignore-for-release
This commit is contained in:
@@ -151,6 +151,12 @@ Trying the file not found case (should fallback to next mode):
|
||||
|
||||
{{< file-tree "content" />}}
|
||||
|
||||
{{< file-tree name="{path}" />}}
|
||||
|
||||
{{< file-tree name="FixIt/apps/test" />}}
|
||||
|
||||
{{< file-tree path="posts" name="{path}" />}}
|
||||
|
||||
### Named parameters
|
||||
|
||||
{{< file-tree path="data" level=2 />}}
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
}
|
||||
|
||||
> .file-tree-label .file-tree-icon::before {
|
||||
content: '\f07b';
|
||||
--fa: '\f07b';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
@param {int} [deep=0] - Current depth level for recursive calls
|
||||
@param {array} [ignoreList] - List of file or folder names to ignore
|
||||
@param {boolean} [isRecursive=false] - Internal flag for recursive calls
|
||||
@param {boolean} [fullRootName=false] - Whether to use the full root path as the root name
|
||||
@param {string} [name] - Project name for the root node, if set to `{path}`, uses the full root path
|
||||
@param {string} [lang] - Page language for multilingual sites
|
||||
@param {boolean} [log=true] - Whether to log warnings
|
||||
@param {boolean} [log=false] - Whether to log warnings
|
||||
@return {array} Array of tree items with structure: {name, type, children?}, or empty array if root doesn't exist
|
||||
*/ -}}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
{{- $isRecursive := .isRecursive | default false -}}
|
||||
{{- $_ignoreList := slice ".DS_Store" "Thumbs.db" ".directory" ".git" "node_modules" "public" -}}
|
||||
{{- $ignoreList := .ignoreList | default slice | union $_ignoreList -}}
|
||||
{{- $fullRootName := .fullRootName | default false -}}
|
||||
{{- $_debug := (site.Store.Get "devOpts").debug -}}
|
||||
|
||||
{{- if $isRecursive -}}
|
||||
@@ -78,9 +77,9 @@
|
||||
{{- if $rootIsExists -}}
|
||||
{{- $f := os.Stat $root -}}
|
||||
{{- /* Determine the root name for display */ -}}
|
||||
{{- $rootLabel := $f.Name -}}
|
||||
{{- $rootLabel := .name | default $f.Name -}}
|
||||
{{- $rootClean := path.Clean $root -}}
|
||||
{{- if $fullRootName | and (ne $rootClean "/") | and (ne $rootClean ".") -}}
|
||||
{{- if eq .name "{path}" -}}
|
||||
{{- $rootLabel = $rootClean -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -93,7 +92,7 @@
|
||||
{{- $result = slice (dict "name" $rootLabel "type" "dir" "children" $children) -}}
|
||||
{{- else -}}
|
||||
{{- /* Root doesn't exist, emit warning if context provided */ -}}
|
||||
{{- if .log | default true -}}
|
||||
{{- if .log | default false -}}
|
||||
{{- warnidf "warning-file-tree" "[get-file-tree]: The root path does not exist: %s." $root -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{{- hugo.Store.Set "version" "v0.4.2-20260109141516-b29368c3" -}}
|
||||
{{- hugo.Store.Set "version" "v0.4.2-20260114101213-fdfd7721" -}}
|
||||
{{- .Store.Set "this" dict -}}
|
||||
|
||||
{{- partial "init/detection-env.html" . -}}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
@param {string} [data] - The name of the data file in data/filetree/ directory. (JSON/YAML/TOML)
|
||||
@param {string} [ignoreList=""] - List of file or folder names to ignore, separated by commas
|
||||
@param {string} [highlightList=""] - List of file or folder names to highlight, separated by commas
|
||||
@param {boolean} [fullRootName=false] - Whether to use the full root path as the root name when scanning filesystem
|
||||
@param {string} [name] - Project name for the root node, if set to `{path}`, uses the full root path
|
||||
|
||||
Priority order (highest to lowest):
|
||||
1. Inline content (shortcode body) - Parse tree data from shortcode body
|
||||
@@ -63,7 +63,6 @@
|
||||
{{- $supportExts := slice ".yml" ".yaml" ".json" ".toml" -}}
|
||||
{{- $ignoreList := union (apply (split (.Get "ignoreList" | default "") ",") "trim" "." " ") $config.ignorelist -}}
|
||||
{{- $highlightList := apply (split (.Get "highlightList" | default "") ",") "trim" "." " " -}}
|
||||
{{- $fullRootName := .Get "fullRootName" | default false -}}
|
||||
|
||||
{{- /* Shortcode body */ -}}
|
||||
{{- $content := strings.TrimSpace .Inner | default "" -}}
|
||||
@@ -100,10 +99,9 @@
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- /* Filesystem mode: scan directory structure */ -}}
|
||||
{{- /* Filesystem mode: build structured tree data from filesystem */ -}}
|
||||
{{- if not $treeData -}}
|
||||
{{- /* Build structured tree data from filesystem */ -}}
|
||||
{{- $buildOptions := dict "root" $root "ignoreList" $ignoreList "deep" 0 "fullRootName" $fullRootName "lang" .Page.Language "log" false -}}
|
||||
{{- $buildOptions := dict "root" $root "ignoreList" $ignoreList "name" (.Get "name") "lang" .Page.Language -}}
|
||||
{{- with partial "function/get-file-tree.html" $buildOptions -}}
|
||||
{{- $treeData = . -}}
|
||||
{{- else -}}
|
||||
|
||||
Reference in New Issue
Block a user