Back to Genai Toolbox

List Tools

.hugo/layouts/shortcodes/list-tools.html

1.1.02.2 KB
Original Source

{{/* Set Database Title */}} {{ $dbTitle := .Page.Title }} {{/* Gather & Pre-filter Native Tools (from the local "tools" sub-folder) */}} {{ $validNativeTools := slice }} {{ $localTools := .Page.GetPage "tools" }} {{ if $localTools }} {{ range $localTools.RegularPages }} {{ if not .Params.is_wrapper }} {{ $validNativeTools = $validNativeTools | append . }} {{ end }} {{ end }} {{ end }} {{/* Track if we've printed the main H3 header yet */}} {{ $headerPrinted := false }} {{/* Display Native Tools ONLY if valid ones exist */}} {{ if gt (len $validNativeTools) 0 }}

{{ $dbTitle }} Tools

{{ $headerPrinted = true }}

Tool NameDescription
{{ range $validNativeTools }}{{ .Title }}
{{ end }}
{{ end }} {{/* Gather & Display Inherited Tools */}} {{ $dirsParam := .Get "dirs" }} {{ if $dirsParam }} {{ range split $dirsParam "," }} {{ $dirPath := trim . " " }} {{ $targetDir := site.GetPage $dirPath }} {{ if $targetDir }} {{/* Since $targetDir is the "tools" folder, the DB name is simply its parent */}} {{ $remoteDbTitle := $targetDir.Parent.Title }} {{/* Pre-filter Inherited Tools */}} {{ $validExternalTools := slice }} {{ range $targetDir.RegularPages }} {{ if not .Params.is_wrapper }} {{ $validExternalTools = $validExternalToolsappend . }} {{ end }} {{ end }} {{ if gt (len $validExternalTools) 0 }} {{/* Print the main H3 if the native tools block didn't already print it */}} {{ if not $headerPrinted }}

{{ $dbTitle }} Tools

{{ $headerPrinted = true }} {{ end }}

_ {{ $dbTitle }} maintains full compatibility with {{ $remoteDbTitle }} , allowing you to use the following tools with this connection:_

Tool NameDescription
{{ range $validExternalTools }}{{ .Title }}
{{ end }}
{{ end }} {{ else }}

Warning: Tool directory '{{ $dirPath }}' not found.

{{ end }} {{ end }} {{ end }} {{/* Fallback if absolutely NO tools exist anywhere */}} {{ if and (not $headerPrinted) (not $dirsParam) }}

No tools found to display.

{{ end }}