[App Search] Fix bash API code example (#106015)

* Fix bash/curl API code example not correctly having `\`s at the end of non-body lines

- Doing this requires removing the `dedent()` fn which is messing up backslashes

- Removing dedent requires setting the template literal indentation to 0 and changing the indent level on DOCUMENTS_API_JSON_EXAMPLE

* I unindented DOCUMENTS_API_JSON_EXAMPLE too hard
- the { is no longer lined up with the [ I think??? what am I even doing with my life
This commit is contained in:
Constance 2021-07-16 16:25:55 -07:00 committed by GitHub
parent 5b68c54568
commit da7c43c1db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 50 deletions

View file

@ -36,34 +36,34 @@ export const DOCUMENT_CREATION_WARNINGS = {
// This is indented the way it is to work with ApiCodeExample.
// Use dedent() when calling this alone
export const DOCUMENTS_API_JSON_EXAMPLE = `[
{
"id": "park_rocky-mountain",
"title": "Rocky Mountain",
"description": "Bisected north to south by the Continental Divide, this portion of the Rockies has ecosystems varying from over 150 riparian lakes to montane and subalpine forests to treeless alpine tundra. Wildlife including mule deer, bighorn sheep, black bears, and cougars inhabit its igneous mountains and glacial valleys. Longs Peak, a classic Colorado fourteener, and the scenic Bear Lake are popular destinations, as well as the historic Trail Ridge Road, which reaches an elevation of more than 12,000 feet (3,700 m).",
"nps_link": "https://www.nps.gov/romo/index.htm",
"states": [
"Colorado"
],
"visitors": 4517585,
"world_heritage_site": false,
"location": "40.4,-105.58",
"acres": 265795.2,
"square_km": 1075.6,
"date_established": "1915-01-26T06:00:00Z"
},
{
"id": "park_saguaro",
"title": "Saguaro",
"description": "Split into the separate Rincon Mountain and Tucson Mountain districts, this park is evidence that the dry Sonoran Desert is still home to a great variety of life spanning six biotic communities. Beyond the namesake giant saguaro cacti, there are barrel cacti, chollas, and prickly pears, as well as lesser long-nosed bats, spotted owls, and javelinas.",
"nps_link": "https://www.nps.gov/sagu/index.htm",
"states": [
"Arizona"
],
"visitors": 820426,
"world_heritage_site": false,
"location": "32.25,-110.5",
"acres": 91715.72,
"square_km": 371.2,
"date_established": "1994-10-14T05:00:00Z"
}
]`;
{
"id": "park_rocky-mountain",
"title": "Rocky Mountain",
"description": "Bisected north to south by the Continental Divide, this portion of the Rockies has ecosystems varying from over 150 riparian lakes to montane and subalpine forests to treeless alpine tundra. Wildlife including mule deer, bighorn sheep, black bears, and cougars inhabit its igneous mountains and glacial valleys. Longs Peak, a classic Colorado fourteener, and the scenic Bear Lake are popular destinations, as well as the historic Trail Ridge Road, which reaches an elevation of more than 12,000 feet (3,700 m).",
"nps_link": "https://www.nps.gov/romo/index.htm",
"states": [
"Colorado"
],
"visitors": 4517585,
"world_heritage_site": false,
"location": "40.4,-105.58",
"acres": 265795.2,
"square_km": 1075.6,
"date_established": "1915-01-26T06:00:00Z"
},
{
"id": "park_saguaro",
"title": "Saguaro",
"description": "Split into the separate Rincon Mountain and Tucson Mountain districts, this park is evidence that the dry Sonoran Desert is still home to a great variety of life spanning six biotic communities. Beyond the namesake giant saguaro cacti, there are barrel cacti, chollas, and prickly pears, as well as lesser long-nosed bats, spotted owls, and javelinas.",
"nps_link": "https://www.nps.gov/sagu/index.htm",
"states": [
"Arizona"
],
"visitors": 820426,
"world_heritage_site": false,
"location": "32.25,-110.5",
"acres": 91715.72,
"square_km": 371.2,
"date_established": "1994-10-14T05:00:00Z"
}
]`;

View file

@ -7,8 +7,6 @@
import React from 'react';
import dedent from 'dedent';
import { useValues, useActions } from 'kea';
import {
@ -107,23 +105,22 @@ export const FlyoutBody: React.FC = () => {
</EuiFlexGroup>
</EuiPanel>
<EuiCodeBlock language="bash" fontSize="m" isCopyable>
{dedent(`
curl -X POST '${documentsApiUrl}'
-H 'Content-Type: application/json'
-H 'Authorization: Bearer ${apiKey}'
-d '${DOCUMENTS_API_JSON_EXAMPLE}'
# Returns
# [
# {
# "id": "park_rocky-mountain",
# "errors": []
# },
# {
# "id": "park_saguaro",
# "errors": []
# }
# ]
`)}
{`\
curl -X POST '${documentsApiUrl}' \\
-H 'Content-Type: application/json' \\
-H 'Authorization: Bearer ${apiKey}' \\
-d '${DOCUMENTS_API_JSON_EXAMPLE}'
# Returns
# [
# {
# "id": "park_rocky-mountain",
# "errors": []
# },
# {
# "id": "park_saguaro",
# "errors": []
# }
# ]`}
</EuiCodeBlock>
</EuiFlyoutBody>
);