Skip to content

Commit c0e3327

Browse files
committed
Add ToC sidebar + some fixes and refactoring
1 parent a088e29 commit c0e3327

23 files changed

+410
-188
lines changed

.github/workflows/preview-build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
if: github.event_name == 'push' || steps.check-files.outputs.any_changed == 'true'
5454
uses: actions/checkout@v4
5555
with:
56+
repository: '${{ github.event.pull_request.head.repo.full_name || github.repository }}'
5657
ref: ${{ github.event.pull_request.head.sha || github.ref }}
5758
persist-credentials: false
5859

@@ -147,7 +148,7 @@ jobs:
147148
--paths "${PATH_PREFIX}" "${PATH_PREFIX}/*"
148149
149150
- name: Update Link Index
150-
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.s3-upload.outcome == 'success'
151+
if: steps.s3-upload.outcome == 'success'
151152
uses: elastic/docs-builder/actions/update-link-index@main
152153

153154
- name: Update deployment status

docs/contribute/index.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,20 @@ Whether you're a technical writer or you've only edited Elastic docs once or twi
1010

1111
## Contribute to the docs [#contribute]
1212

13-
The version of the docs you want to contribute to determines the tool and syntax you must use to update the docs.
14-
15-
### Contribute to Elastic Stack version 8.x docs and earlier
16-
17-
To contribute to earlier versions of the Elastic Stack, you must work with our [legacy documentation build system](https://github.com/elastic/docs). This system uses AsciiDoc as it's authoring format.
18-
19-
* For **simple bugfixes and enhancements** --> [Contribute on the web](on-the-web.md)
20-
* For **complex or multi-page updates** --> See the [legacy documentation build guide](https://github.com/elastic/docs?tab=readme-ov-file#building-documentation)
21-
22-
### Contribute to Elastic Stack version 9.0 docs and later
23-
24-
* For **simple bugfixes and enhancements** --> [contribute on the web](on-the-web.md)
25-
* For **complex or multi-page updates** --> [Contribute locally](locally.md)
13+
* Simple bugs and enhancements --> [Contribute on the web](on-the-web.md)
14+
* Complex or multi-page updates --> [Contribute locally](locally.md)
15+
* Test migrated content --> [Migration guide](../migration/guide/index.md)
2616

2717
## Report a bug
2818

2919
* It's a **documentation** problem --> [Open a docs issue](https://github.com/elastic/docs-content/issues/new?template=internal-request.yaml) *or* [Fix it myself](locally.md)
3020
* It's a **build tool (docs-builder)** problem --> [Open a bug report](https://github.com/elastic/docs-builder/issues/new?template=bug-report.yaml)
21+
* It's a **migration tooling** problem --> [Open a bug report](https://github.com/elastic/docs-builder/issues/new?template=bug-report.yaml)
3122

3223
## Request an enhancement
3324

3425
* Make the **documentation** better --> [Open a docs issue](https://github.com/elastic/docs-content/issues/new?template=internal-request.yaml)
35-
* Make our **build tool (docs-builder)** better --> [Start a docs-builder discussion](https://github.com/elastic/docs-builder/discussions)
26+
* Make our **build tool (docs-builder)** better --> [Open a docs-builder issue](https://github.com/elastic/docs-builder/issues/new?template=enhancement.yaml)
3627

3728
## Work on docs-builder
3829

docs/contribute/locally.md

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,13 @@
11
# Contribute locally
22

33
Follow these steps to contribute to Elastic docs.
4-
5-
* [Prerequisites](#prerequisites)
64
* [Step 1: Install `docs-builder`](#step-one)
7-
* [Step 2: Clone a content repository](#step-two)
5+
* [Step 2: Clone the `docs-content` repository](#step-two)
86
* [Step 3: Serve the Documentation](#step-three)
9-
* [Step 4: Write docs!](#step-four)
10-
* [Step 5: Push your changes](#step-five)
11-
12-
## Prerequisites
13-
14-
To write and push updates to Elastic documentation, you need the following:
15-
16-
1. **A code editor**: we recommend [Visual Studio Code](https://code.visualstudio.com/download)
17-
1. **Git installed on your machine**: learn how [here](https://github.com/git-guides/install-git)
18-
1. **A GitHub account**: sign up [here](https://github.com/)
7+
* [Step 4: Open a PR](#step-three)
198

209
## Step 1: Install `docs-builder` [#step-one]
2110

22-
There are two different ways to install and run `docs-builder`:
23-
24-
1. Download, extract, and run the binary (recommended)
25-
1. Clone the repository and build the binary from source
26-
27-
This guide uses option one. If you'd like to clone the repository and build from source, learn how in the [project readme](https://github.com/elastic/docs-builder?tab=readme-ov-file#docs-builder).
28-
2911
::::{tab-set}
3012

3113
:::{tab-item} macOS
@@ -45,7 +27,7 @@ This guide uses option one. If you'd like to clone the repository and build from
4527
```
4628

4729
3. **Run the Binary:**
48-
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
30+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the docset.yml file that you want to build can be specified with `-p`:
4931
```sh
5032
./docs-builder serve -p ./path/to/docs
5133
```
@@ -69,7 +51,7 @@ This guide uses option one. If you'd like to clone the repository and build from
6951
```
7052

7153
3. **Run the Binary:**
72-
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
54+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the docset.yml file that you want to build can be specified with `-p`:
7355
```sh
7456
.\docs-builder serve -p ./path/to/docs
7557
```
@@ -93,7 +75,7 @@ This guide uses option one. If you'd like to clone the repository and build from
9375
```
9476

9577
3. **Run the Binary:**
96-
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
78+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the docset.yml file that you want to build can be specified with `-p`:
9779
```sh
9880
./docs-builder serve -p ./path/to/docs
9981
```
@@ -102,28 +84,22 @@ This guide uses option one. If you'd like to clone the repository and build from
10284

10385
::::
10486

105-
## Clone a content repository [#step-two]
106-
107-
:::{tip}
108-
Documentation lives in many repositories across Elastic. If you're unsure which repository to clone, you can use the "Edit this page" link on any documentation page to determine where the source file lives.
109-
:::
87+
## Clone the `docs-content` Repository [#step-two]
11088

111-
In this guide, we'll clone the [`docs-content`](https://github.com/elastic/docs-content) repository. The `docs-content` repository is the home for narrative documentation at Elastic. Clone this repo to a directory of your choice:
89+
Clone the `docs-content` repository to a directory of your choice:
11290
```sh
11391
git clone https://github.com/elastic/docs-content.git
11492
```
11593

11694
## Serve the Documentation [#step-three]
11795

118-
1. **Navigate to the `docs-builder` clone location:**
96+
1. **Navigate to the cloned repository:**
11997
```sh
12098
cd docs-content
12199
```
122100

123-
1. **Run the Binary:**
124-
Run the binary with the `serve` command to build and serve the content set to http://localhost:3000. Specify the path to the `docset.yml` file that you want to build with `-p`.
125-
126-
For example, if `docs-builder` and `docs-content` are in the same top-level directory, you would run:
101+
2. **Run the Binary:**
102+
Use the `serve` command to start serving the documentation at http://localhost:3000. The path to the `docset.yml` file that you want to build can be specified with `-p`:
127103
```sh
128104
# macOS/Linux
129105
./docs-builder serve -p ./migration-test
@@ -134,16 +110,9 @@ git clone https://github.com/elastic/docs-content.git
134110

135111
Now you should be able to view the documentation locally by navigating to http://localhost:3000.
136112

137-
## Step 4: Write docs [#step-four]
138-
139-
We write docs in markdown. See our [syntax](../syntax/index.md) guide for the flavor of markdown that we support and all of our custom directives that enable you to add a little extra pizazz to your docs.
140-
141-
## Step 5: Push your changes [#step-five]
142-
143-
After you've made your changes locally,
113+
## Step 4: Open a PR [#step-four]
144114

145-
* [Push your commits](https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository)
146-
* [Open a Pull Request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request)
115+
Open a PR. Good luck.
147116

148117
## Step 5: View on elastic.co/docs
149118

docs/docset.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ external_hosts:
2121
- github.io
2222
- github.com
2323
- elastic.dev
24-
- visualstudio.com
2524
exclude:
2625
- '_*.md'
2726
subs:

docs/versions/_snippets/content-patterns-list.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
| [Section/heading-level `applies` tags](/versions/content-patterns.md#sectionheading-level-applies-tags) | Provide signals about a section’s scope so a user can choose to read or skip it as needed. |
55
| [Tabs](/versions/content-patterns.md#tabs) | Provide two sets of procedures when one or more steps in a process differs between contexts or versions. |
66
| [Callouts](/versions/content-patterns.md#callouts) | Draw attention to happy differences and basic clarifications. |
7-
| [Prose](/versions/content-patterns.md#prose) | - Identify features in a list of features that are exclusive to a specific context, or that were introduced in a specific version<br>- List differing requirements, limits, and other simple, mirrored facts<br>- Provide clarifying or secondary information<br>- Explain differences with a "why" (e.g. comparative overviews) |
7+
| [Prose](/versions/content-patterns.md#prose) | Provide clarifying or secondary information, explain differences with a "why". |
88
| [Sibling pages](/versions/content-patterns.md#sibling-pages) | When the information is too complex to be addressed with only the other content patterns. See specific examples in the sibling pages section. |
99

1010
% | [List item suffixes](/versions/content-patterns.md#list-item-suffixes) | Identify features in a **list of features** that are exclusive to a specific context, or that were introduced in a specific version. |

docs/versions/content-patterns.md

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,12 @@ If there’s a terminology change or other minor change (especially where x equa
208208

209209
## Prose
210210

211-
**Use cases:**
212-
* When features in a list of features are exclusive to a specific context, or were introduced in a specific version
213-
* Requirements, limits, other simple, mirrored facts
211+
**Use case**: Clarifying or secondary information, differences with a "why"
212+
213+
**When to use:**
214214
* Cases where the information isn’t wildly important, but nice to know, or to add basic terminology change info to overviews
215215
* Comparative overviews
216-
* Differences that are small enough or not significant enough to warrant an admonition or tabs or separate sections with front matter
216+
* Differences that are small enough or not significant enough to warrant an admonition or tabs or separate sections with frontmatter.
217217

218218
In some cases, you might want to add a paragraph specific to one version or another in prose to clarify behavior or terminology.
219219

@@ -223,44 +223,12 @@ In cases where there are significant differences between contexts, close explana
223223

224224
### Examples
225225

226+
* In {{stack}} 9.1.0 and earlier, **Spaces** were referred to as **Places**.
226227

227228
::::{tab-set}
228-
:group: five-six-four-one-three
229-
230-
:::{tab-item} Unique features
231-
:sync: five
232-
233-
* Each space has its own saved objects.
234-
* Users can only access the spaces that they have been granted access to. This access is based on user roles, and a given role can have different permissions per space.
235-
* In {{stack}} 9.0.0+, each space has its own navigation.
236-
237-
:::
238-
239-
:::{tab-item} Unique reqs / limits
240-
:sync: six
241-
242-
* In serverless, use `Admin` or equivalent
243-
* In {{stack}} 9.0.0+, use `kibana_admin` or equivalent
244-
245-
OR
246-
247-
The maximum number of spaces that you can have differs by [what do we call this]:
248-
249-
* In serverless, you can have a maximum of 100 spaces.
250-
* In {{stack}} 9.0.0+, the maximum is controlled by the `xpack.spaces.maxSpaces` setting. Default is 1000.
251-
:::
229+
:group: one-two-three
252230

253-
:::{tab-item} Nice-to-know
254-
:sync: four
255-
256-
In {{stack}} 9.1.0 and earlier, **Spaces** were referred to as **Places**.
257-
258-
OR
259-
260-
If you're managing a {{stack}} v9 deployment, then you can also assign roles and define permissions for a space from the **Permissions** tab of the space settings.
261-
:::
262-
263-
:::{tab-item} Comparative overviews
231+
:::{tab-item} One
264232
:sync: one
265233

266234
The way that TLS certificates are managed depends on your deployment type:
@@ -272,7 +240,12 @@ In {{eck}}, you can manage certificates for the HTTP layer. Certificates for the
272240
In {{ece}}, you can use one or more proxy certificates to secure the HTTP layer. These certificates are managed at the ECE installation level. Transport-level encryption is managed by ECE and certificates can’t be changed.
273241
:::
274242

275-
:::{tab-item} Comparative overviews II
243+
:::{tab-item} Two
244+
:sync: two
245+
If you're managing a {{stack}} v9 deployment, then you can also assign roles and define permissions for a space from the **Permissions** tab of the space settings.
246+
:::
247+
248+
:::{tab-item} Three
276249
:sync: three
277250

278251
**Managed security in Elastic Cloud**
@@ -291,7 +264,6 @@ You can augment Elastic Cloud security features in the following ways:
291264
:::
292265
::::
293266

294-
295267
## Sibling pages
296268

297269
**Use case:**
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import {initNav} from "./pages-nav";
2+
import {initTocNav} from "./toc-nav";
3+
24
import {initHighlight} from "./hljs";
35

46
initNav();
7+
initTocNav();
58
initHighlight();
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#elastic-docs-v3 {
2+
ol,ul {
3+
font-family: "Inter", sans-serif;
4+
@apply text-base text-body mb-6;
5+
line-height: 1.5em;
6+
letter-spacing: 0;
7+
margin-left: 1.5em;
8+
}
9+
10+
ol {
11+
list-style-type: decimal;
12+
}
13+
14+
ul {
15+
list-style-type: disc;
16+
}
17+
18+
li {
19+
margin-bottom: calc(var(--spacing) * 3);
20+
21+
p {
22+
margin-bottom: 0;
23+
}
24+
}
25+
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
#elastic-docs-v3 {
2+
23
h1 {
34
font-family: "Mier B", "Inter", sans-serif;
4-
@apply text-4xl text-ink font-bold mb-6;
5+
@apply text-4xl text-black mb-6 mt-4;
56
line-height: 1.2em;
67
letter-spacing: -0.04em;
78
}
89

910
h2 {
1011
font-family: "Mier B", "Inter", sans-serif;
11-
@apply text-2xl text-ink mb-6;
12+
@apply text-2xl text-black mb-6 mt-4;
1213
line-height: 1.2em;
1314
letter-spacing: -0.02em;
1415
}
1516

1617
h3 {
1718
font-family: "Mier B", "Inter", sans-serif;
18-
@apply text-xl text-ink font-bold mb-6;
19+
@apply text-xl text-black font-bold mb-6 mt-4;
1920
line-height: 1.2em;
2021
letter-spacing: -0.02em;
2122
}
2223

2324
p {
2425
font-family: "Inter", sans-serif;
25-
@apply text-base text-body mb-6;
26+
@apply text-base text-ink text-body mb-6;
2627
line-height: 1.5em;
2728
letter-spacing: 0;
2829
}
2930

3031
a {
3132
font-family: "Inter", sans-serif;
32-
@apply text-blue-elastic hover:underline underline-offset-4;
33+
@apply text-blue-elastic underline hover:text-blue-800;
3334
}
3435
}

src/Elastic.Markdown/Assets/pages-nav.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import {$, $$} from "select-dom/strict";
1+
import {$, $$} from "select-dom";
22

33
type NavExpandState = { [key: string]: boolean };
44
const PAGE_NAV_EXPAND_STATE_KEY = 'pagesNavState';
5-
const navState = JSON.parse(sessionStorage.getItem(PAGE_NAV_EXPAND_STATE_KEY)) as NavExpandState
5+
const navState = JSON.parse(sessionStorage.getItem(PAGE_NAV_EXPAND_STATE_KEY) ?? "{}") as NavExpandState
66

77
// Initialize the nav state from the session storage
88
// Return a function to keep the nav state in the session storage that should be called before the page is unloaded
@@ -14,7 +14,9 @@ function keepNavState(nav: HTMLElement): () => void {
1414
if ('shouldExpand' in input.dataset && input.dataset['shouldExpand'] === 'true') {
1515
input.checked = true;
1616
} else {
17-
input.checked = navState[key];
17+
if (key in navState) {
18+
input.checked = navState[key];
19+
}
1820
}
1921
});
2022
}
@@ -68,6 +70,9 @@ function isElementInViewport(el: HTMLElement): boolean {
6870

6971
export function initNav() {
7072
const pagesNav = $('#pages-nav');
73+
if (!pagesNav) {
74+
return;
75+
}
7176
const keepNavStateCallback = keepNavState(pagesNav);
7277
const keepNavPositionCallback = keepNavPosition(pagesNav);
7378
scrollCurrentNaviItemIntoView(pagesNav, 100);

0 commit comments

Comments
 (0)