Browse Source

Merge pull request #20525 from abpframework/doctitle

Show H1 tag value for page titles
pull/20465/head
oykuermann 2 years ago
committed by GitHub
parent
commit
85d808efd0
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 9
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

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

@ -197,7 +197,6 @@ namespace Volo.Docs.Pages.Documents.Project
await SetNavigationAsync(); await SetNavigationAsync();
SetLanguageSelectListItems(); SetLanguageSelectListItems();
SetDocumentPageTitle();
return Page(); return Page();
} }
@ -472,7 +471,12 @@ namespace Volo.Docs.Pages.Documents.Project
private void SetDocumentPageTitle() private void SetDocumentPageTitle()
{ {
DocumentPageTitle = Navigation.FindNavigation(DocumentNameWithExtension)?.Text ?? DocumentName?.Replace("-", " "); DocumentPageTitle = DocumentName?.Replace("-", " ");
var match = Regex.Match(Document.Content, @"#(?<PageTitle>.+)");
if (match.Success && match.Groups.TryGetValue("PageTitle", out var group))
{
DocumentPageTitle = Regex.Replace(group.Value, "<.*?>", string.Empty).Trim();
}
} }
public string CreateVersionLink(VersionInfoViewModel latestVersion, string version, string documentName = null) public string CreateVersionLink(VersionInfoViewModel latestVersion, string version, string documentName = null)
@ -508,6 +512,7 @@ namespace Volo.Docs.Pages.Documents.Project
Document = await GetSpecificDocumentOrDefaultAsync(language); Document = await GetSpecificDocumentOrDefaultAsync(language);
DocumentLanguageCode = language; DocumentLanguageCode = language;
DocumentNameWithExtension = Document.Name; DocumentNameWithExtension = Document.Name;
SetDocumentPageTitle();
await ConvertDocumentContentToHtmlAsync(); await ConvertDocumentContentToHtmlAsync();
return true; return true;
} }

Loading…
Cancel
Save