Skip to content

Commit 745486b

Browse files
committed
Add latest header design and adjust pages navigation
1 parent 232421a commit 745486b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+648
-176
lines changed

.github/workflows/preview-build.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,21 @@ jobs:
133133
- name: Build documentation
134134
if: github.repository != 'elastic/docs-builder' && (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group'))
135135
uses: elastic/docs-builder@main
136-
id: docs-build
137136
continue-on-error: ${{ fromJSON(inputs.continue-on-error != '' && inputs.continue-on-error || 'false') }}
138137
with:
139138
prefix: ${{ env.PATH_PREFIX }}
140139
strict: ${{ fromJSON(inputs.strict != '' && inputs.strict || 'true') }}
141140

142141
- name: 'Validate Inbound Links'
143-
if: ${{ !cancelled() && steps.docs-build.outputs.skip != 'true' && (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group')) }}
144142
uses: elastic/docs-builder/actions/validate-inbound-local@main
145-
continue-on-error: true
143+
if: ${{ !cancelled() && (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group')) }}
146144

147145
- uses: elastic/docs-builder/.github/actions/aws-auth@main
148-
if: ${{ !cancelled() && steps.docs-build.outputs.skip != 'true' && steps.deployment.outputs.result }}
146+
if: ${{ !cancelled() && steps.deployment.outputs.result }}
149147

150148
- name: Upload to S3
151149
id: s3-upload
152-
if: ${{ !cancelled() && steps.docs-build.outputs.skip != 'true' && steps.deployment.outputs.result }}
150+
if: ${{ !cancelled() && steps.deployment.outputs.result }}
153151
run: |
154152
aws s3 sync .artifacts/docs/html "s3://elastic-docs-v3-website-preview${PATH_PREFIX}" --delete
155153
aws cloudfront create-invalidation \
@@ -160,10 +158,6 @@ jobs:
160158
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.s3-upload.outcome == 'success'
161159
uses: elastic/docs-builder/actions/update-link-index@main
162160

163-
- name: Update Reference Index
164-
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.s3-upload.outcome == 'success'
165-
uses: elastic/docs-builder/actions/update-reference-index@main
166-
167161
- name: Update deployment status
168162
uses: actions/github-script@v7
169163
if: always() && steps.deployment.outputs.result
@@ -175,7 +169,7 @@ jobs:
175169
owner: context.repo.owner,
176170
repo: context.repo.repo,
177171
deployment_id: ${{ steps.deployment.outputs.result }},
178-
state: "${{ steps.docs-build.outputs.skip == 'true' && 'inactive' || (steps.s3-upload.outcome == 'success' && 'success' || 'failure') }}",
172+
state: "${{ steps.s3-upload.outcome == 'success' && 'success' || 'failure' }}",
179173
environment_url: `https://docs-v3-preview.elastic.dev${process.env.PATH_PREFIX}`,
180174
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
181175
})

.github/workflows/preview-cleanup.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,3 @@ jobs:
5151
PR_NUMBER: ${{ github.event.pull_request.number }}
5252
run: |
5353
aws s3 rm "s3://elastic-docs-v3-website-preview/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" --recursive
54-
55-
- name: 'Update Reference Index'
56-
uses: elastic/docs-builder/actions/update-reference-index@main

action.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ inputs:
1212
strict:
1313
description: 'Treat warnings as errors'
1414
required: false
15-
outputs:
16-
skip:
17-
description: "hint from the documentation tool to skip the docs build for this PR"
1815

1916
runs:
2017
using: 'docker'

actions/generator/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: 'Documentation Generator'
2+
description: 'Generates a random yet deterministic documentation set'
3+
4+
branding:
5+
icon: 'filter'
6+
color: 'red'
7+
8+
inputs:
9+
output:
10+
description: 'Path to output the documentation'
11+
required: false
12+
13+
runs:
14+
using: 'docker'
15+
image: "docker://ghcr.io/elastic/docs-generator:edge"
16+

actions/update-reference-index/action.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs-builder.sln

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "validate-inbound-local", "v
6060
actions\validate-inbound-local\action.yml = actions\validate-inbound-local\action.yml
6161
EndProjectSection
6262
EndProject
63-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "update-link-index", "update-link-index", "{6554F917-73CE-4B3D-9101-F28EAA762C6B}"
64-
ProjectSection(SolutionItems) = preProject
65-
actions\update-link-index\action.yml = actions\update-link-index\action.yml
66-
actions\update-link-index\README.md = actions\update-link-index\README.md
67-
EndProjectSection
68-
EndProject
69-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "update-reference-index", "update-reference-index", "{9FEC15F6-13F8-40B1-A66A-EB054E49E680}"
70-
ProjectSection(SolutionItems) = preProject
71-
actions\update-reference-index\action.yml = actions\update-reference-index\action.yml
72-
EndProjectSection
73-
EndProject
7463
Global
7564
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7665
Debug|Any CPU = Debug|Any CPU
@@ -130,7 +119,5 @@ Global
130119
{CFEE9FAD-9E0C-4C0E-A0C2-B97D594C14B5} = {245023D2-D3CA-47B9-831D-DAB91A2FFDC7}
131120
{4CCE599A-B9FE-4DF2-8763-34CF0A99D4AA} = {BE6011CC-1200-4957-B01F-FCCA10C5CF5A}
132121
{6E2ED6CC-AFC1-4E58-965D-6AEC500EBB46} = {245023D2-D3CA-47B9-831D-DAB91A2FFDC7}
133-
{6554F917-73CE-4B3D-9101-F28EAA762C6B} = {245023D2-D3CA-47B9-831D-DAB91A2FFDC7}
134-
{9FEC15F6-13F8-40B1-A66A-EB054E49E680} = {245023D2-D3CA-47B9-831D-DAB91A2FFDC7}
135122
EndGlobalSection
136123
EndGlobal

docs/_docset.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ subs:
99
serverless-short: Serverless
1010
ece: "Elastic Cloud Enterprise"
1111
eck: "Elastic Cloud on Kubernetes"
12+
13+
#features:
14+
# PrimaryNav: true
15+
1216
toc:
1317
- file: index.md
1418
- hidden: developer-notes.md

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function scrollCurrentNaviItemIntoView(nav: HTMLElement, delay: number) {
1515
const currentNavItem = $('.current', nav);
1616
expandAllParents(currentNavItem);
1717
setTimeout(() => {
18-
1918
if (currentNavItem && !isElementInViewport(currentNavItem)) {
2019
currentNavItem.scrollIntoView({ behavior: 'smooth', block: 'center' });
20+
window.scrollTo(0, 0);
2121
}
2222
}, delay);
2323
}
@@ -36,7 +36,7 @@ export function initNav() {
3636
if (!pagesNav) {
3737
return;
3838
}
39-
const navItems = $$('a[href="' + window.location.pathname + '"]', pagesNav);
39+
const navItems = $$('a[href="' + window.location.pathname + '"], a[href="' + window.location.pathname + '/"]', pagesNav);
4040
navItems.forEach(el => {
4141
el.classList.add('current');
4242
});

src/Elastic.Markdown/Assets/styles.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,19 @@
7272

7373
.sidebar {
7474
.sidebar-nav {
75-
@apply sticky top-22 z-30 overflow-y-auto;
75+
@apply sticky top-21 z-30 overflow-y-auto;
7676
max-height: calc(100vh - var(--spacing) * 22);
77+
scrollbar-gutter: stable;
7778
}
7879

7980
.sidebar-link {
8081
@apply
8182
text-ink-light
8283
hover:text-black
8384
text-sm
84-
leading-[1.2em]
85+
text-wrap
86+
inline-block
87+
leading-[1.3em]
8588
tracking-[-0.02em];
8689
}
8790
}

src/Elastic.Markdown/Helpers/Htmx.cs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,50 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5+
using System.Text;
6+
using Elastic.Markdown.IO.Configuration;
7+
58
namespace Elastic.Markdown.Helpers;
69

7-
public class Htmx
10+
public static class Htmx
811
{
9-
public static string GetHxSelectOob() => "#markdown-content,#toc-nav,#prev-next-nav,#breadcrumbs";
12+
public static string GetHxSelectOob(ConfigurationFile configuration, string? pathPrefix, string currentUrl, string targetUrl)
13+
{
14+
HashSet<string> selectTargets =
15+
[
16+
"#primary-nav", "#secondary-nav", "#markdown-content", "#toc-nav", "#prev-next-nav", "#breadcrumbs"
17+
];
18+
if (!HasSameTopLevelGroup(pathPrefix, currentUrl, targetUrl) && configuration.Features.ContainsKey("PrimaryNav"))
19+
_ = selectTargets.Add("#pages-nav");
20+
return string.Join(',', selectTargets);
21+
}
22+
23+
public static bool HasSameTopLevelGroup(string? pathPrefix, string currentUrl, string targetUrl)
24+
{
25+
var startIndex = pathPrefix?.Length ?? 0;
26+
var currentSegments = GetSegments(currentUrl[startIndex..].Trim('/'));
27+
var targetSegments = GetSegments(targetUrl[startIndex..].Trim('/'));
28+
return currentSegments.Length >= 1 && targetSegments.Length >= 1 && currentSegments[0] == targetSegments[0];
29+
}
30+
31+
public static string GetPreload() => "true";
32+
33+
public static string GetHxSwap() => "none";
34+
public static string GetHxPushUrl() => "true";
35+
public static string GetHxIndicator() => "#htmx-indicator";
36+
37+
private static string[] GetSegments(string url) => url.Split('/');
38+
39+
public static string GetHxAttributes(ConfigurationFile configuration, string? pathPrefix, string currentUrl, string targetUrl)
40+
{
41+
42+
var attributes = new StringBuilder();
43+
_ = attributes.Append($" hx-get={targetUrl}");
44+
_ = attributes.Append($" hx-select-oob={GetHxSelectOob(configuration, pathPrefix, currentUrl, targetUrl)}");
45+
_ = attributes.Append($" hx-swap={GetHxSwap()}");
46+
_ = attributes.Append($" hx-push-url={GetHxPushUrl()}");
47+
_ = attributes.Append($" hx-indicator={GetHxIndicator()}");
48+
_ = attributes.Append($" preload={GetPreload()}");
49+
return attributes.ToString();
50+
}
1051
}

0 commit comments

Comments
 (0)