updated children shortcode to show code examples when provided in the frontmatter

pull/851/head
Scott Anderson 2020-03-20 11:01:37 -06:00
parent db423159dd
commit 0582681680
5 changed files with 72 additions and 24 deletions

View File

@ -75,6 +75,7 @@ related: # Creates links to specific internal and external content at the bottom
external_url: # Used in children shortcode type="list" for page links that are external
list_image: # Image included with article descriptions in children type="articles" shortcode
list_note: # Used in children shortcode type="list" to add a small note next to listed links
list_code_example: # Code example included with article descriptions in children type="articles" shortcode
```
#### Title usage
@ -406,17 +407,29 @@ The following list types are available:
- **list:** lists children article links in an unordered list.
- **functions:** a special use-case designed for listing Flux functions.
#### Include a code example with a child summary
Use the `list_code_example` frontmatter to provide a code example with an article
in an articles list.
~~~yaml
list_code_example: |
```sh
This is a code example
```
~~~
#### Children frontmatter
Each children list `type` uses [frontmatter properties](#page-frontmatter) when generating the list of articles.
The following table shows which children types use which frontmatter properties:
| Frontmatter | articles | list | functions |
|:----------- |:--------:|:----:|:---------:|
| `list_title` | ✓ | ✓ | ✓ |
| `description` | ✓ | | |
| `external_url` | ✓ | ✓ | |
| `list_image` | ✓ | | |
| `list_note` | | ✓ | |
| Frontmatter | articles | list | functions |
|:----------- |:--------:|:----:|:---------:|
| `list_title` | ✓ | ✓ | ✓ |
| `description` | ✓ | | |
| `external_url` | ✓ | ✓ | |
| `list_image` | ✓ | | |
| `list_note` | | ✓ | |
| `list_code_example` | ✓ | | |
### Inline icons
The `icon` shortcode allows you to inject icons in paragraph text.

View File

@ -7,6 +7,16 @@ menu:
name: Filter by region
parent: Geo-temporal data
weight: 302
list_code_example: |
```js
import "experimental/geo"
sampleGeoData
|> geo.filterRows(
region: {lat: 30.04, lon: 31.23, radius: 200.0},
strict: true
)
```
---
Use the [`geo.fitlerRows` function](/v2.0/reference/flux/stdlib/geo/filterrows/)

View File

@ -7,6 +7,14 @@ menu:
v2_0:
parent: Geo-temporal data
weight: 302
list_code_example: |
```js
import "experimental/geo"
sampleGeoData
|> geo.groupByArea(newColumn: "geoArea", level: 5)
|> geo.asTracks(groupBy: ["id"],sortBy: ["_time"])
```
---
Use the `geo.groupByArea()` and `geo.asTracks()` functions to group geo-temporal

View File

@ -8,6 +8,21 @@ menu:
name: Shape geo-temporal data
parent: Geo-temporal data
weight: 301
list_code_example: |
```js
import "experimental/geo"
sampleGeoData
|> map(fn: (r) => ({ r with
_field:
if r._field == "latitude" then "lat"
else if r._field == "longitude" then "lon"
else r._field
}))
|> map(fn: (r) => ({ r with
s2_cell_id: geo.s2CellIDToken(point: {lon: r.lon, lat: r.lat}, level: 10)
}))
```
---
Functions in the Geo package require the following data schema:
@ -18,9 +33,24 @@ Functions in the Geo package require the following data schema:
- a **`lon` field** field containing the **longitude in decimal degrees** (WGS 84)
<!-- -->
- [Generate S2 cell ID tokens](#generate-s2-cell-id-tokens)
- [Rename latitude and longitude fields](#rename-latitude-and-longitude-fields)
- [Generate S2 cell ID tokens](#generate-s2-cell-id-tokens)
## Rename latitude and longitude fields
Use [`map()`](/v2.0/reference/flux/stdlib/built-in/transformations/map/) to rename
existing latitude and longitude fields keys using other names.
```js
from(bucket: "example-bucket")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "example-measurement")
|> map(fn: (r) => ({ r with
_field:
if r._field == "existingLatitudeField" then "lat"
else if r._field == "existingLongitudeField" then "lon"
else r._field
}))
```
## Generate S2 cell ID tokens
The Geo package uses the [S2 Geometry Library](https://s2geometry.io/) which
@ -89,19 +119,3 @@ from(bucket: "example-bucket")
s2_cell_id: geo.s2CellIDToken(point: {lon: r.lon, lat: r.lat}, level: 10)
}))
```
## Rename latitude and longitude fields
Use [`map()`](/v2.0/reference/flux/stdlib/built-in/transformations/map/) to rename
existing latitude and longitude fields keys using other names.
```js
from(bucket: "example-bucket")
|> range(start: -1h)
|> filter(fn: (r) => r._measurement == "example-measurement")
|> map(fn: (r) => ({ r with
_field:
if r._field == "existingLatitudeField" then "lat"
else if r._field == "existingLongitudeField" then "lon"
else r._field
}))
```

View File

@ -35,6 +35,9 @@
<img src='{{ $img }}'/>
{{ end }}
{{ end }}
{{ if .Params.list_code_example }}
{{ .Params.list_code_example | markdownify }}
{{ end }}
{{ end }}
{{ else if (eq $type "functions") }}