added description method and description tag

pull/3488/head
Akın Sabri Çam 6 years ago
parent be32a55449
commit e25b844aca

@ -39,7 +39,10 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>@pageTitle</title>
@if (ViewBag.Description!=null)
{
<meta name="description" content="@ViewBag.Description" />
}
<abp-style-bundle name="@BasicThemeBundles.Styles.Global" />
@await Component.InvokeAsync(typeof(WidgetStylesViewComponent))

@ -19,6 +19,7 @@
ViewBag.FluidLayout = true;
Layout = ThemeManager.CurrentTheme.GetEmptyLayout();
PageLayout.Content.Title = Model.DocumentName?.Replace("-", " ");
ViewBag.Description = Model.GetDescription();
}
@section styles {
<abp-style-bundle name="@typeof(IndexModel).FullName">

@ -2,7 +2,9 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.Extensions.Logging;
@ -64,7 +66,7 @@ namespace Volo.Docs.Pages.Documents.Project
public DocumentParametersDto DocumentPreferences { get; set; }
public DocumentRenderParameters UserPreferences { get; set; } = new DocumentRenderParameters();
public bool FullSearchEnabled { get; set; }
private readonly IDocumentAppService _documentAppService;
@ -591,5 +593,17 @@ namespace Volo.Docs.Pages.Documents.Project
}
}
}
public string GetDescription()
{
var startIndex = Document.Content.IndexOf("<p>", StringComparison.Ordinal);
var lastIndex = Document.Content.IndexOf("</p>", StringComparison.Ordinal);
var description = Document.Content.Substring(startIndex,lastIndex);
Regex rx = new Regex("<[^>]*>");
description = rx.Replace(description, "");
return description.Truncate(200);
}
}
}

Loading…
Cancel
Save