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
parent
commit
ed1b6196a1
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 21
      modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/NavigationNode.cs
  2. 2
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml
  3. 9
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

21
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 DateTime? LastSignificantUpdateTime { get; set; }
public bool IsSelected(string documentName) public bool IsSelected(string documentName)
{
return FindNavigation(documentName) != null;
}
public NavigationNode FindNavigation(string documentName)
{ {
if (documentName == null) if (documentName == null)
{ {
return false; return null;
} }
var path = Path ?? string.Empty; var path = Path ?? string.Empty;
var pathHasExtension = System.IO.Path.HasExtension(path); var pathHasExtension = System.IO.Path.HasExtension(path);
@ -44,26 +49,26 @@ namespace Volo.Docs.Documents
path = path.EnsureEndsWith('/') + "index" + extension; path = path.EnsureEndsWith('/') + "index" + extension;
} }
if (string.Equals(documentName, path, StringComparison.OrdinalIgnoreCase)) if (string.Equals(documentName, path, StringComparison.OrdinalIgnoreCase))
{ {
return true; return this;
} }
if (Items == null) if (Items == null)
{ {
return false; return null;
} }
foreach (var childItem in Items) 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;
} }
} }

2
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml

@ -28,7 +28,7 @@
@{ @{
ViewBag.FluidLayout = true; ViewBag.FluidLayout = true;
Layout = ThemeManager.CurrentTheme.GetEmptyLayout(); Layout = ThemeManager.CurrentTheme.GetEmptyLayout();
PageLayout.Content.Title = Model.DocumentName?.Replace("-", " "); PageLayout.Content.Title = Model.DocumentPageTitle;
ViewBag.Description = Model.GetDescription(); ViewBag.Description = Model.GetDescription();
ViewBag.CanonicalUrl = Model.IsLatestVersion ? null : Model.GetFullUrlOfTheLatestDocument(); //issue #12355 ViewBag.CanonicalUrl = Model.IsLatestVersion ? null : Model.GetFullUrlOfTheLatestDocument(); //issue #12355
} }

9
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

@ -57,6 +57,8 @@ namespace Volo.Docs.Pages.Documents.Project
public List<SelectListItem> LanguageSelectListItems { get; set; } public List<SelectListItem> LanguageSelectListItems { get; set; }
public string DocumentNameWithExtension { get; private set; } public string DocumentNameWithExtension { get; private set; }
public string DocumentPageTitle { get; private set; }
public DocumentWithDetailsDto Document { get; private set; } public DocumentWithDetailsDto Document { get; private set; }
@ -195,6 +197,7 @@ namespace Volo.Docs.Pages.Documents.Project
await SetNavigationAsync(); await SetNavigationAsync();
SetLanguageSelectListItems(); SetLanguageSelectListItems();
SetDocumentPageTitle();
return Page(); return Page();
} }
@ -459,12 +462,18 @@ namespace Volo.Docs.Pages.Documents.Project
Version = Version Version = Version
} }
); );
} }
catch (DocumentNotFoundException) //TODO: What if called on a remote service which may return 404 catch (DocumentNotFoundException) //TODO: What if called on a remote service which may return 404
{ {
return; return;
} }
} }
private void SetDocumentPageTitle()
{
DocumentPageTitle = Navigation.FindNavigation(DocumentNameWithExtension)?.Text ?? DocumentName?.Replace("-", " ");
}
public string CreateVersionLink(VersionInfoViewModel latestVersion, string version, string documentName = null) public string CreateVersionLink(VersionInfoViewModel latestVersion, string version, string documentName = null)
{ {

Loading…
Cancel
Save