{{/* {{< code-snippet path="/documentation/headless/snippets/points-id/" order="python http go" > */}} {{/* {{< code-snippet path="/path/to/snippets" order="snippet1 snippet2" > */}} {{ $path := .Get "path" }} {{ $order := .Get "order" }} {{ if $order }} {{ $order = split $order " " }} {{ end }} {{ if not $order }} {{ $currentPath := $path }} {{ $foundOrder := false }} {{ $currentPathParts := split $currentPath "/" }} {{ $numParts := len $currentPathParts }} {{ range seq $numParts }} {{ $index := sub $numParts . }} {{ $currentPath = delimit (first (add $index 1) $currentPathParts) "/" }} {{ $sectionPage := $.Site.GetPage "section" $currentPath }} {{ if and $sectionPage $sectionPage.Params.snippetsOrder }} {{ $order = $sectionPage.Params.snippetsOrder }} {{ $foundOrder = true }} {{ break }} {{ end }} {{ end }} {{ if not $foundOrder }} {{ $order = slice }} {{ end }} {{ end }} {{ $files := slice }} {{ range (readDir (printf "content/%s" $path)) }} {{ if strings.HasPrefix .Name "_" }} {{ continue }} {{ end }} {{ if strings.HasSuffix .Name ".md" }} {{ $filePath := printf "content/%s/%s" $path .Name }} {{ $content := readFile $filePath | markdownify }} {{ $files = $files | append (dict "name" (strings.TrimSuffix ".md" .Name) "content" $content) }} {{ end }} {{ end }} {{ range $order }} {{ $snippet := index (where $files "name" .) 0 }} {{ if $snippet }} {{ $snippet.content | markdownify }} {{ end }} {{ end }} {{ range $files }} {{ if not (in $order .name) }} {{ .content | markdownify }} {{ end }} {{ end }}