Skip to content

Conversation

@Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Jun 10, 2025

Hidden is a pure navigation property now as its removed from MarkdownFile.
NavigationIndex is a pure navigation property now as its removed from MarkdownFile.

GetCurrentNavigation() is now non nullable

…utViewModel`. Streamline layout handling, enhance navigation item visibility logic, and rework documentation file structures for improved maintainability.

`Hidden` is a pure navigation property now as its removed from `MarkdownFile`.

`GetCurrentNavigation()` is now non nullable
@Mpdreamz Mpdreamz requested a review from a team as a code owner June 10, 2025 16:50
@Mpdreamz Mpdreamz added the chore label Jun 10, 2025
@Mpdreamz Mpdreamz self-assigned this Jun 10, 2025
@Mpdreamz Mpdreamz added the chore label Jun 10, 2025
@Mpdreamz Mpdreamz requested a review from Copilot June 10, 2025 16:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors markdown and layout rendering by decoupling from GlobalLayoutViewModel and streamlining navigation handling. Key changes include:

  • Converting the current navigation item to a non-nullable property and moving the hidden state from MarkdownFile to navigation items.
  • Updating view files to use a new MarkdownLayoutViewModel and removing legacy layout switches.
  • Adjusting navigation and link metadata creation, including enhanced error handling in GetCurrent navigation lookup.

Reviewed Changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Elastic.Markdown/Slices/IndexViewModel.cs Made CurrentNavigationItem non-nullable to align with new GetCurrentNavigation contract.
src/Elastic.Markdown/Slices/Index.cshtml Updated layout model and added a meta section for products when applicable.
src/Elastic.Markdown/Slices/HtmlWriter.cs Swapped use of markdown.Hidden for current.Hidden in AllowIndexing condition.
src/Elastic.Markdown/Myst/FrontMatter/FrontMatterParser.cs Added required using directive for updated slices.
src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs Updated FileNavigationItem record to include a Hidden property and adjusted navigation items generation.
src/Elastic.Markdown/IO/MarkdownFile.cs Removed the Hidden property as it is now a navigation concern.
src/Elastic.Markdown/IO/DocumentationSet.cs Updated GetCurrent to be non-nullable with explicit exception on missing navigation; adjusted previous/next logic and link metadata accordingly.
src/Elastic.Documentation.Site/_ViewModels.cs Revised GlobalLayoutViewModel to remove legacy properties and include updated members.
src/Elastic.Documentation.Site/_GlobalLayout.cshtml Removed layout switching logic in favor of a simplified render body and footer section.
src/Elastic.Documentation.Site/Navigation/_TocTreeNav.cshtml Filtered out hidden navigation items before rendering.
src/Elastic.Documentation.Site/Navigation/INavigationItem.cs Added Hidden boolean to the navigation item interface.
src/Elastic.Documentation.Site/Layout/_SecondaryNav.cshtml Updated conditional check to use RenderHamburgerIcon from the new layout model.
src/Elastic.Documentation.Site/Layout/_Head.cshtml Removed legacy product meta tags in favor of new layout model usage.
src/Elastic.ApiExplorer (Operations, Landing, Endpoints) Removed legacy properties and standardized navigation items with a default Hidden property.
Comments suppressed due to low confidence (4)

src/Elastic.Markdown/IO/DocumentationSet.cs:39

  • Confirm that callers of GetCurrent properly handle the potential InvalidOperationException when a navigation item for the given file is not found.
MarkdownNavigationLookup.GetValueOrDefault(file.CrossLink) ?? throw new InvalidOperationException($"Could not find {file.CrossLink} in navigation")

src/Elastic.Markdown/Slices/HtmlWriter.cs:107

  • Ensure that the 'current' variable referenced here is properly defined in the enclosing scope so that its Hidden property is reliably accessed at runtime.
AllowIndexing = DocumentationSet.Context.AllowIndexing && (markdown is DetectionRuleFile || !current.Hidden)

src/Elastic.Markdown/IO/Navigation/DocumentationGroup.cs:16

  • The addition of the 'Hidden' parameter in FileNavigationItem standardizes navigation visibility; please ensure that all consumers of this record are updated to accommodate the new field.
public record FileNavigationItem(MarkdownFile Model, DocumentationGroup Group, bool Hidden = false)

src/Elastic.Documentation.Site/_GlobalLayout.cshtml:23

  • Ensure that all pages define a footer section; otherwise, rendering this section may lead to runtime errors.
@await RenderSectionAsync(GlobalSections.Footer)

public IReadOnlyDictionary<Uri, TocReference> TocReferences { get; } =
Children.OfType<TocReference>().ToDictionary(kv => kv.Source, kv => kv);

public bool IsPhantom { get; init; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a comment what IsPhantom means? 🙏

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good callout! I did my best to explain their purpose in 05f89cc

@Mpdreamz Mpdreamz enabled auto-merge (squash) June 11, 2025 15:51
@Mpdreamz Mpdreamz merged commit 8df9149 into main Jun 11, 2025
15 checks passed
@Mpdreamz Mpdreamz deleted the refactor/navigation-2 branch June 11, 2025 15:57
Mpdreamz added a commit that referenced this pull request Jun 11, 2025
…utViewModel`. Streamline layout handling, enhance navigation item visibility logic, and rework documentation file structures for improved maintainability. (#1353)

* Refactor markdown and layout rendering by decoupling from `GlobalLayoutViewModel`. Streamline layout handling, enhance navigation item visibility logic, and rework documentation file structures for improved maintainability.

`Hidden` is a pure navigation property now as its removed from `MarkdownFile`.

`GetCurrentNavigation()` is now non nullable

* Ensure NavigationIndex is a navigation property.

* Update advertising of landing-page-path

* update landing page path output

* Add xmldocs for IsPhantom

(cherry picked from commit 8df9149)
Mpdreamz added a commit that referenced this pull request Jun 12, 2025
#1357)

* Refactor markdown and layout rendering by decoupling from `GlobalLayoutViewModel`. Streamline layout handling, enhance navigation item visibility logic, and rework documentation file structures for improved maintainability. (#1353)

* Refactor markdown and layout rendering by decoupling from `GlobalLayoutViewModel`. Streamline layout handling, enhance navigation item visibility logic, and rework documentation file structures for improved maintainability.

`Hidden` is a pure navigation property now as its removed from `MarkdownFile`.

`GetCurrentNavigation()` is now non nullable

* Ensure NavigationIndex is a navigation property.

* Update advertising of landing-page-path

* update landing page path output

* Add xmldocs for IsPhantom

(cherry picked from commit 8df9149)

* Ensure links.json considers all navigation items

(cherry picked from commit 40f1332d45593f7c0bbbaf08ac540807ad5b5395)

* remove commented line

* update test file output order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants