Browse Source
Merge pull request #20429 from abpframework/doctitle
Show Document navigation text for page title
pull/20517/head
oykuermann
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
23 additions and
9 deletions
-
modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/NavigationNode.cs
-
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml
-
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -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 |
|
|
|
} |
|
|
|
|
|
|
|
@ -57,6 +57,8 @@ namespace Volo.Docs.Pages.Documents.Project |
|
|
|
public List<SelectListItem> 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) |
|
|
|
{ |
|
|
|
|