simplified children shortcode, made it multi-use

pull/46/head
Scott Anderson 2019-02-06 08:42:58 -07:00
parent 9b4b49de6b
commit 56f1be7ac5
5 changed files with 28 additions and 90 deletions

View File

@ -2,11 +2,11 @@
title: Execute queries
seotitle: Different ways to query InfluxDB
description: There are multiple ways to query data from InfluxDB including the the InfluxDB UI, CLI, and API.
weight: 2
menu:
v2_0:
name: Execute queries
parent: Query data
weight: 2
---
There are multiple ways to execute queries with InfluxDB.

View File

@ -3,11 +3,11 @@ title: Get started with Flux
description: >
Get started with Flux, InfluxData's functional data scripting language.
This step-by-step guide through the basics of writing a Flux query.
weight: 1
menu:
v2_0:
name: Get started with Flux
parent: Query data
weight: 1
---
Flux is InfluxData's functional data scripting language designed for querying,

View File

@ -1,11 +1,11 @@
---
title: Flux how-to guides
description: Helpful guides that walk through both common and complex tasks and use cases for Flux.
weight: 3
menu:
v2_0:
name: How-to guides
parent: Query data
weight: 3
---
The following guides walk through common query uses cases.

View File

@ -11,4 +11,4 @@ menu:
Flux input functions define sources of data or display information about data sources.
The following input functions are available:
{{< function-list category="Inputs" menu="v2_0_ref" >}}
{{< children type="functions" >}}

View File

@ -1,90 +1,28 @@
{{ $showhidden := .Get "showhidden"}}
{{ $style := .Get "style" | default "h3" }}
{{ $depth := .Get "depth" | default 1 }}
{{ $withDescription := .Get "description" | default true }}
{{ $sortTerm := .Get "sort" | default "Weight" }}
{{ $pages := union .Page.Pages .Page.Sections }}
{{ $type := .Get "type" | default "articles" }}
<div class="children-links">
{{ .Scratch.Set "pages" .Page.Pages }}
{{ if .Page.Sections}}
{{ .Scratch.Set "pages" (.Page.Pages | union .Page.Sections) }}
{{end}}
{{ $pages := (.Scratch.Get "pages") }}
{{ if eq $type "articles" }}
{{ range $pages.ByWeight }}
<h3><a href="{{ .RelPermalink }}" >{{ .Title }}</a></h3>
<p>
{{- if .Description }}{{- .Description -}}
{{ else }}{{- .Summary -}}
{{ end -}}
</p>
{{ end }}
{{ else if (eq $type "functions") }}
<ul>
{{ range $pages.ByWeight }}
{{ $title := replaceRE `\(\)\ function` "" .Title }}
<li><a href="{{ .RelPermalink }}">{{ $title }}</a></li>
{{ end }}
<ul>
{{ end }}
{{if eq $sortTerm "Weight"}}
{{template "childs" dict "menu" $pages.ByWeight "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
{{else if eq $sortTerm "Name"}}
{{template "childs" dict "menu" $pages.ByTitle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
{{else if eq $sortTerm "PublishDate"}}
{{template "childs" dict "menu" $pages.ByPublishDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
{{else if eq $sortTerm "Date"}}
{{template "childs" dict "menu" $pages.ByDate "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
{{else if eq $sortTerm "Length"}}
{{template "childs" dict "menu" $pages.ByLength "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
{{else}}
{{template "childs" dict "menu" $pages "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm}}
{{end}}
</div>
{{.Inner|safeHTML}}
{{ define "childs" }}
{{ range .menu }}
{{ if and .Params.hidden (not $.showhidden) }}
{{else}}
{{if hasPrefix $.style "h"}}
{{$num := sub ( int (trim $.style "h") ) 1 }}
{{$numn := add $num $.count }}
{{(printf "<h%d>" $numn)|safeHTML}}
<a href="{{.URL}}" >{{ .Title }}</a>
{{(printf "</h%d>" $numn)|safeHTML}}
{{else}}
{{(printf "<%s>" $.style)|safeHTML}}
<a href="{{.URL}}" >{{ .Title }}</a>
{{(printf "</%s>" $.style)|safeHTML}}
{{end}}
{{if $.description}}
{{if .Description}}
<p>{{.Description}}</p>
{{else}}
<p>{{.Summary}}</p>
{{end}}
{{end}}
{{ if lt $.count $.depth}}
{{if eq $.style "li"}}
<div>
{{end}}
{{ $.Page.Scratch.Set "pages" .Pages }}
{{ if .Sections}}
{{ $.Page.Scratch.Set "pages" (.Pages | union .Sections) }}
{{end}}
{{ $pages := ($.Page.Scratch.Get "pages") }}
{{if eq $.sortTerm "Weight"}}
{{template "childs" dict "menu" $pages.ByWeight "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
{{else if eq $.sortTerm "Name"}}
{{template "childs" dict "menu" $pages.ByTitle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
{{else if eq $.sortTerm "PublishDate"}}
{{template "childs" dict "menu" $pages.ByPublishDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
{{else if eq $.sortTerm "Date"}}
{{template "childs" dict "menu" $pages.ByDate "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
{{else if eq $.sortTerm "Length"}}
{{template "childs" dict "menu" $pages.ByLength "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
{{else}}
{{template "childs" dict "menu" $pages "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm}}
{{end}}
{{if eq $.style "li"}}
</ul>
{{end}}
{{end}}
{{end}}
{{end}}
{{end}}