diff --git a/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/NavigationNode.cs b/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/NavigationNode.cs index 6ecf7eb204..2f1afce342 100644 --- a/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/NavigationNode.cs +++ b/modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/NavigationNode.cs @@ -29,12 +29,17 @@ namespace Volo.Docs.Documents public DateTime? LastSignificantUpdateTime { get; set; } public bool IsSelected(string documentName) + { + return FindNavigation(documentName) != null; + } + + public NavigationNode FindNavigation(string documentName) { if (documentName == null) { - return false; + return null; } - + var path = Path ?? string.Empty; var pathHasExtension = System.IO.Path.HasExtension(path); @@ -44,26 +49,26 @@ namespace Volo.Docs.Documents path = path.EnsureEndsWith('/') + "index" + extension; } - if (string.Equals(documentName, path, StringComparison.OrdinalIgnoreCase)) { - return true; + return this; } if (Items == null) { - return false; + return null; } foreach (var childItem in Items) { - if (childItem.IsSelected(documentName)) + var node = childItem.FindNavigation(documentName); + if (node != null) { - return true; + return node; } } - return false; + return null; } } diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml index b60ad9507f..9507da66ce 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml @@ -28,7 +28,7 @@ @{ ViewBag.FluidLayout = true; Layout = ThemeManager.CurrentTheme.GetEmptyLayout(); - PageLayout.Content.Title = Model.DocumentName?.Replace("-", " "); + PageLayout.Content.Title = Model.DocumentPageTitle; ViewBag.Description = Model.GetDescription(); ViewBag.CanonicalUrl = Model.IsLatestVersion ? null : Model.GetFullUrlOfTheLatestDocument(); //issue #12355 } diff --git a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs index 109aed3ed4..c80b81bf71 100644 --- a/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs +++ b/modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs @@ -57,6 +57,8 @@ namespace Volo.Docs.Pages.Documents.Project public List LanguageSelectListItems { get; set; } public string DocumentNameWithExtension { get; private set; } + + public string DocumentPageTitle { get; private set; } public DocumentWithDetailsDto Document { get; private set; } @@ -195,6 +197,7 @@ namespace Volo.Docs.Pages.Documents.Project await SetNavigationAsync(); SetLanguageSelectListItems(); + SetDocumentPageTitle(); return Page(); } @@ -459,12 +462,18 @@ namespace Volo.Docs.Pages.Documents.Project Version = Version } ); + } catch (DocumentNotFoundException) //TODO: What if called on a remote service which may return 404 { return; } } + + private void SetDocumentPageTitle() + { + DocumentPageTitle = Navigation.FindNavigation(DocumentNameWithExtension)?.Text ?? DocumentName?.Replace("-", " "); + } public string CreateVersionLink(VersionInfoViewModel latestVersion, string version, string documentName = null) {