diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b5d1fe948..d744780ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. diff --git a/content/v2.0/query-data/flux/geo/filter-by-region.md b/content/v2.0/query-data/flux/geo/filter-by-region.md index b9ef1debf..e788a6f54 100644 --- a/content/v2.0/query-data/flux/geo/filter-by-region.md +++ b/content/v2.0/query-data/flux/geo/filter-by-region.md @@ -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/) diff --git a/content/v2.0/query-data/flux/geo/group-geo-data.md b/content/v2.0/query-data/flux/geo/group-geo-data.md index caa1df440..a0519387b 100644 --- a/content/v2.0/query-data/flux/geo/group-geo-data.md +++ b/content/v2.0/query-data/flux/geo/group-geo-data.md @@ -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 diff --git a/content/v2.0/query-data/flux/geo/shape-geo-data.md b/content/v2.0/query-data/flux/geo/shape-geo-data.md index 790e9e125..9a688928e 100644 --- a/content/v2.0/query-data/flux/geo/shape-geo-data.md +++ b/content/v2.0/query-data/flux/geo/shape-geo-data.md @@ -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 - })) -``` diff --git a/layouts/shortcodes/children.html b/layouts/shortcodes/children.html index 360d44bc9..f24ca8051 100644 --- a/layouts/shortcodes/children.html +++ b/layouts/shortcodes/children.html @@ -35,6 +35,9 @@ {{ end }} {{ end }} + {{ if .Params.list_code_example }} + {{ .Params.list_code_example | markdownify }} + {{ end }} {{ end }} {{ else if (eq $type "functions") }}