-
Notifications
You must be signed in to change notification settings - Fork 32
Improve versioning system inference #2070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
using Elastic.Documentation; | ||
using Elastic.Documentation.Configuration.LegacyUrlMappings; | ||
using Elastic.Documentation.Configuration.Products; | ||
using Elastic.Documentation.Configuration.TableOfContents; | ||
using Elastic.Documentation.Configuration.Versions; | ||
using Elastic.Documentation.Site.FileProviders; | ||
using Elastic.Documentation.Site.Navigation; | ||
|
@@ -102,9 +103,27 @@ private async Task<RenderResult> RenderLayout(MarkdownFile markdown, MarkdownDoc | |
fullNavigationRenderResult | ||
); | ||
|
||
var currentBaseVersion = legacyPages is { Count: > 0 } | ||
? $"{legacyPages.ElementAt(0).Product.VersioningSystem?.Base.Major}.{legacyPages.ElementAt(0).Product.VersioningSystem?.Base.Minor}+" | ||
: $"{DocumentationSet.Context.VersionsConfiguration.VersioningSystems[VersioningSystemId.Stack].Base.Major}.{DocumentationSet.Context.VersionsConfiguration.VersioningSystems[VersioningSystemId.Stack].Base.Minor}+"; | ||
// Acquiring the versioning system for the current page: | ||
// 1. If the page has a legacy page mapping, use the versioning system of the legacy page | ||
// 2. If the page's docset has a name with a direct product maatch, use the versioning system of the product | ||
// 3. If the page's docset has a table of contents entry with a direct product match, use the versioning system of the product | ||
// 4. Fallback to the stack versioning system | ||
VersioningSystem pageVersioning = null!; | ||
if (legacyPages is not null && legacyPages.Count > 0) | ||
pageVersioning = legacyPages.ElementAt(0).Product.VersioningSystem!; | ||
else if (DocumentationSet.Context.ProductsConfiguration.Products.TryGetValue(DocumentationSet.Name, out var belonging)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets use Git.RepositoryName explicitly over |
||
pageVersioning = belonging.VersioningSystem!; | ||
else if (DocumentationSet.Configuration.TableOfContents.FirstOrDefault(t => t is TocReference tRef && !tRef.Source.LocalPath.Equals("/")) is TocReference tocRef) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is clever I wonder if its too clever though? What are the cases where this is needed? |
||
{ | ||
var productFound = DocumentationSet.Context.ProductsConfiguration.Products.TryGetValue(tocRef.Source.LocalPath.Trim('/'), out var tocProduct); | ||
if (productFound && tocProduct is not null) | ||
pageVersioning = tocProduct.VersioningSystem!; | ||
} | ||
else | ||
pageVersioning = DocumentationSet.Context.VersionsConfiguration.VersioningSystems[VersioningSystemId.Stack]; | ||
|
||
var currentBaseVersion = $"{pageVersioning.Base.Major}.{pageVersioning.Base.Minor}+"; | ||
|
||
//TODO should we even distinctby | ||
var breadcrumbs = parents.Reverse().DistinctBy(p => p.Url).ToArray(); | ||
var breadcrumbsList = CreateStructuredBreadcrumbsData(markdown, breadcrumbs); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this to an isolated place like
LegacyPageService
or something new