diff --git a/src/Elastic.Markdown/Assets/main.ts b/src/Elastic.Markdown/Assets/main.ts index 559f77d07..e20fb4745 100644 --- a/src/Elastic.Markdown/Assets/main.ts +++ b/src/Elastic.Markdown/Assets/main.ts @@ -1,5 +1,5 @@ // @ts-nocheck -import "htmx.org" +import htmx from "htmx.org" import "htmx-ext-preload" import {initTocNav} from "./toc-nav"; import {initHighlight} from "./hljs"; @@ -7,20 +7,6 @@ import {initTabs} from "./tabs"; import {initCopyButton} from "./copybutton"; import {initNav} from "./pages-nav"; import {$, $$} from "select-dom" -import { UAParser } from 'ua-parser-js'; -const { getOS } = new UAParser(); - -document.addEventListener('htmx:beforeRequest', function(event) { - if (event.detail.requestConfig.verb === 'get' && event.detail.requestConfig.triggeringEvent) { - const { ctrlKey, metaKey, shiftKey }: PointerEvent = event.detail.requestConfig.triggeringEvent; - const { name: os } = getOS(); - const modifierKey: boolean = os === 'macOS' ? metaKey : ctrlKey; - if (shiftKey || modifierKey) { - event.preventDefault(); - window.open(event.detail.requestConfig.path, '_blank', 'noopener,noreferrer'); - } - } -}); document.addEventListener('htmx:load', function() { initTocNav(); diff --git a/src/Elastic.Markdown/Assets/styles.css b/src/Elastic.Markdown/Assets/styles.css index 99a8da0a4..5bccadc70 100644 --- a/src/Elastic.Markdown/Assets/styles.css +++ b/src/Elastic.Markdown/Assets/styles.css @@ -20,7 +20,34 @@ --outline-offset: 5; --header-height: calc(var(--spacing) * 21); --banner-height: calc(var(--spacing) * 9); - --offset-top: calc(var(--header-height) + var(--banner-height)); + /*--offset-top: calc(var(--header-height) + var(--banner-height));*/ + --offset-top: 72px; +} + +@media screen and (min-width: 767px) { + :root { + --offset-top: 123px; + } +} + +@media screen and (min-width: 992px) { + :root { + --offset-top: 131px; + } +} + + + +/*@media screen and (min-width: 767px) {*/ +/* :root {*/ +/* --offset-top: 131px;*/ +/* }*/ +/*}*/ + +@media screen and (min-width: 1200px) { + :root { + --offset-top: 72px; + } } /*#default-search::-webkit-search-cancel-button {*/ @@ -95,7 +122,7 @@ @apply text-ink-light hover:text-black - lg:text-sm + md:text-sm text-wrap inline-block leading-[1.3em] @@ -187,3 +214,9 @@ .markdown-content { @apply font-body; } + +.container { + @apply lg:px-3; + + max-width: 1250px !important; +} diff --git a/src/Elastic.Markdown/Assets/theme.css b/src/Elastic.Markdown/Assets/theme.css index b9318cc9d..f31bf9da4 100644 --- a/src/Elastic.Markdown/Assets/theme.css +++ b/src/Elastic.Markdown/Assets/theme.css @@ -1,5 +1,12 @@ @theme { + + --breakpoint-sm: 40rem; + --breakpoint-md: 768px; + --breakpoint-lg: 1280px; + --breakpoint-xl: 1920px; + --breakpoint-2xl: 2000px; + --font-sans: "Mier B", "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; --font-body: "Inter", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; diff --git a/src/Elastic.Markdown/Extensions/DetectionRules/DetectionRulesDocsBuilderExtension.cs b/src/Elastic.Markdown/Extensions/DetectionRules/DetectionRulesDocsBuilderExtension.cs index c7a3c2e54..0bceb1f1c 100644 --- a/src/Elastic.Markdown/Extensions/DetectionRules/DetectionRulesDocsBuilderExtension.cs +++ b/src/Elastic.Markdown/Extensions/DetectionRules/DetectionRulesDocsBuilderExtension.cs @@ -21,12 +21,13 @@ public void CreateNavigationItem( List groups, List navigationItems, int depth, + bool inNav, ref int fileIndex, int index) { var detectionRulesFolder = (RulesFolderReference)tocItem; var children = detectionRulesFolder.Children; - var group = new DocumentationGroup(Build, lookups with { TableOfContents = children }, ref fileIndex, depth + 1) + var group = new DocumentationGroup(Build, lookups with { TableOfContents = children }, ref fileIndex, depth + 1, inNav) { Parent = parent }; diff --git a/src/Elastic.Markdown/Extensions/IDocsBuilderExtension.cs b/src/Elastic.Markdown/Extensions/IDocsBuilderExtension.cs index 816b4668a..3fa32ac4a 100644 --- a/src/Elastic.Markdown/Extensions/IDocsBuilderExtension.cs +++ b/src/Elastic.Markdown/Extensions/IDocsBuilderExtension.cs @@ -11,9 +11,6 @@ namespace Elastic.Markdown.Extensions; public interface IDocsBuilderExtension { - /// Return true if this extension handles Navigation injection - bool InjectsIntoNavigation(ITocItem tocItem); - /// Inject items into the current navigation void CreateNavigationItem( DocumentationGroup? parent, @@ -22,10 +19,14 @@ void CreateNavigationItem( List groups, List navigationItems, int depth, + bool inNav, ref int fileIndex, int index ); + /// Return true if this extension handles Navigation injection + bool InjectsIntoNavigation(ITocItem tocItem); + /// Visit the and its equivalent void Visit(DocumentationFile file, ITocItem tocItem); diff --git a/src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs b/src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs index b6984b10c..5ab17cd6d 100644 --- a/src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs +++ b/src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs @@ -168,6 +168,7 @@ private List ReadChildren(YamlStreamReader reader, KeyValuePair? children = null; foreach (var entry in tocEntry.Children) { @@ -177,6 +178,10 @@ private List ReadChildren(YamlStreamReader reader, KeyValuePair ReadChildren(YamlStreamReader reader, KeyValuePair ReadChildren(YamlStreamReader reader, KeyValuePair Children) : ITocItem; -public record FolderReference(string Path, bool Found, IReadOnlyCollection Children) : ITocItem; +public record FolderReference(string Path, bool Found, bool InNav, IReadOnlyCollection Children) : ITocItem; diff --git a/src/Elastic.Markdown/IO/DocumentationSet.cs b/src/Elastic.Markdown/IO/DocumentationSet.cs index a0dea68e4..f30eaf323 100644 --- a/src/Elastic.Markdown/IO/DocumentationSet.cs +++ b/src/Elastic.Markdown/IO/DocumentationSet.cs @@ -109,7 +109,7 @@ public DocumentationSet(BuildContext build, ILoggerFactory logger, ICrossLinkRes FilesGroupedByFolder = FilesGroupedByFolder }; - Tree = new DocumentationGroup(Build, lookups, ref fileIndex) + Tree = new DocumentationGroup(Build, lookups, false, ref fileIndex) { Parent = null }; diff --git a/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs b/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs index 696bd179d..4a2fec523 100644 --- a/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs +++ b/src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information using System.IO.Abstractions; +using System.Text.RegularExpressions; using Elastic.Markdown.Diagnostics; using Elastic.Markdown.Extensions; using Elastic.Markdown.Extensions.DetectionRules; @@ -43,11 +44,14 @@ public class DocumentationGroup public int Depth { get; } + public bool InNav { get; } + public DocumentationGroup( BuildContext context, NavigationLookups lookups, + bool inNav, ref int fileIndex) - : this(context, lookups, ref fileIndex, depth: 0) + : this(context, lookups, ref fileIndex, depth: 0, inNav) { } @@ -56,6 +60,7 @@ internal DocumentationGroup( NavigationLookups lookups, ref int fileIndex, int depth, + bool inNav, MarkdownFile? index = null) { Depth = depth; @@ -63,7 +68,7 @@ internal DocumentationGroup( if (Index is not null) Index.GroupId = Id; - + InNav = inNav; GroupsInOrder = groups; FilesInOrder = files; NavigationItems = navigationItems; @@ -119,9 +124,8 @@ internal DocumentationGroup( { if (file.Hidden) context.EmitError(context.ConfigurationPath, $"The following file is hidden but has children: {file.Path}"); - var group = new DocumentationGroup( - context, lookups with { TableOfContents = file.Children }, ref fileIndex, depth + 1, virtualIndex) + context, lookups with { TableOfContents = file.Children }, ref fileIndex, depth + 1, InNav, virtualIndex) { Parent = this }; @@ -153,7 +157,7 @@ .. documentationFiles ]; } - var group = new DocumentationGroup(context, lookups with { TableOfContents = children }, ref fileIndex, depth + 1) + var group = new DocumentationGroup(context, lookups with { TableOfContents = children }, ref fileIndex, depth + 1, folder.InNav) { Parent = this }; @@ -165,7 +169,7 @@ .. documentationFiles foreach (var extension in lookups.EnabledExtensions) { if (extension.InjectsIntoNavigation(tocItem)) - extension.CreateNavigationItem(this, tocItem, lookups, groups, navigationItems, depth, ref fileIndex, index); + extension.CreateNavigationItem(this, tocItem, lookups, groups, navigationItems, depth, false, ref fileIndex, index); } } } diff --git a/src/Elastic.Markdown/Slices/HtmlWriter.cs b/src/Elastic.Markdown/Slices/HtmlWriter.cs index 19b4b6f29..b960617ca 100644 --- a/src/Elastic.Markdown/Slices/HtmlWriter.cs +++ b/src/Elastic.Markdown/Slices/HtmlWriter.cs @@ -28,7 +28,8 @@ private async Task RenderNavigation(string topLevelGroupId, MarkdownFile Tree = group ?? DocumentationSet.Tree, CurrentDocument = markdown, IsRoot = topLevelGroupId == DocumentationSet.Tree.Id, - Features = DocumentationSet.Configuration.Features + Features = DocumentationSet.Configuration.Features, + TopLevelItems = DocumentationSet.Tree.NavigationItems.OfType().ToList() }); return await slice.RenderAsync(cancellationToken: ctx); } diff --git a/src/Elastic.Markdown/Slices/Layout/_Breadcrumbs.cshtml b/src/Elastic.Markdown/Slices/Layout/_Breadcrumbs.cshtml index 709b0c5a3..ee9aec865 100644 --- a/src/Elastic.Markdown/Slices/Layout/_Breadcrumbs.cshtml +++ b/src/Elastic.Markdown/Slices/Layout/_Breadcrumbs.cshtml @@ -7,7 +7,7 @@ href="@Model.Link("/")" > - Home + Docs diff --git a/src/Elastic.Markdown/Slices/Layout/_Header.cshtml b/src/Elastic.Markdown/Slices/Layout/_Header.cshtml index 4f56bc7d6..24afcafe0 100644 --- a/src/Elastic.Markdown/Slices/Layout/_Header.cshtml +++ b/src/Elastic.Markdown/Slices/Layout/_Header.cshtml @@ -101,81 +101,8 @@ ] }; } -
- -
-
- - Elastic - - @if (Model.Features.IsPrimaryNavEnabled) - { - @await RenderPartialAsync(_PrimaryNav.Create(primaryNavViewModel)) - } - else - { -
- } - - -
- - - -
-
-
-
+
+ @if (Model.Features.IsPrimaryNavEnabled) { @await RenderPartialAsync(_SecondaryNav.Create(Model)) diff --git a/src/Elastic.Markdown/Slices/Layout/_LandingPage.cshtml b/src/Elastic.Markdown/Slices/Layout/_LandingPage.cshtml index 3fa0df9c9..b06ec612f 100644 --- a/src/Elastic.Markdown/Slices/Layout/_LandingPage.cshtml +++ b/src/Elastic.Markdown/Slices/Layout/_LandingPage.cshtml @@ -6,7 +6,7 @@
Loading
-
+

Elastic documentation

@@ -26,7 +26,7 @@
-
+

Elastic basics

@@ -48,7 +48,7 @@
-
+

Instant Elasticsearch

@@ -71,10 +71,10 @@
-
+

Elastic products

-
+
Search logo @@ -96,7 +96,7 @@

Resolve problems with open, flexible, and unified observability powered by advanced machine learning and analytics.

@@ -119,25 +119,25 @@
-
+

Elastic how-to guides

Manage all your data

Learn how to ingest, enrich, and manage your data throughout its entire Elasticsearch lifecycle.

-
-
+
Elastic Community logo @@ -263,10 +263,10 @@
-
+

References

-
+

Elastic APIs

Browse the API documentation.

@@ -400,14 +400,14 @@
-
+

Product resources

-
+

Releases

Explore the latest features and changes in Elastic.

-
+
View release notes @@ -423,7 +423,7 @@

Troubleshoot and support

Check troubleshooting guides for common fixes or reach out to the experts.

-
+
Start troubleshooting @@ -439,7 +439,7 @@

Contribute and extend

Learn how to contribute to Elastic products and extend Elastic capabilities.

-
+
Start contributing diff --git a/src/Elastic.Markdown/Slices/Layout/_PagesNav.cshtml b/src/Elastic.Markdown/Slices/Layout/_PagesNav.cshtml index 2183bee47..0d266954c 100644 --- a/src/Elastic.Markdown/Slices/Layout/_PagesNav.cshtml +++ b/src/Elastic.Markdown/Slices/Layout/_PagesNav.cshtml @@ -1,5 +1,6 @@ @inherits RazorSlice -