diff --git a/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Documents/DocumentTemplateDto.cs b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Documents/DocumentTemplateDto.cs index 37d94b9032..75883375cb 100644 --- a/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Documents/DocumentTemplateDto.cs +++ b/modules/docs/src/Volo.Docs.Application.Contracts/Volo/Docs/Documents/DocumentTemplateDto.cs @@ -8,8 +8,6 @@ namespace Volo.Docs.Documents public string Path { get; set; } - public List SelfParameters { get; set; } - - public List ParentParameters { get; set; } + public List Parameters { get; set; } } } \ No newline at end of file diff --git a/modules/docs/src/Volo.Docs.Web/HtmlConverting/ScribanDocumentSectionRenderer.cs b/modules/docs/src/Volo.Docs.Web/HtmlConverting/ScribanDocumentSectionRenderer.cs index fedf8406f3..344a61e538 100644 --- a/modules/docs/src/Volo.Docs.Web/HtmlConverting/ScribanDocumentSectionRenderer.cs +++ b/modules/docs/src/Volo.Docs.Web/HtmlConverting/ScribanDocumentSectionRenderer.cs @@ -134,22 +134,21 @@ namespace Volo.Docs.HtmlConverting var afterJsonOpener = documentContent.Substring( documentContent.IndexOf(jsonOpener, StringComparison.Ordinal) + jsonOpener.Length); - var json = afterJsonOpener.Substring(0, + var betweenJsonOpenerAndCloser = afterJsonOpener.Substring(0, afterJsonOpener.IndexOf(jsonCloser, StringComparison.Ordinal)); documentContent = afterJsonOpener.Substring( afterJsonOpener.IndexOf(jsonCloser, StringComparison.Ordinal) + jsonCloser.Length); - if (!json.Contains(docs_templates)) + if (!betweenJsonOpenerAndCloser.Contains(docs_templates)) { continue; } - json = json.Substring(json.IndexOf(docs_templates, StringComparison.Ordinal) + docs_templates.Length); + var json = betweenJsonOpenerAndCloser.Substring(betweenJsonOpenerAndCloser.IndexOf(docs_templates, StringComparison.Ordinal) + docs_templates.Length); var template = JsonConvert.DeserializeObject(json); - templates.Add(template); } @@ -168,18 +167,18 @@ namespace Volo.Docs.HtmlConverting var afterJsonOpener = document.Substring( document.IndexOf(jsonOpener, StringComparison.Ordinal) + jsonOpener.Length); - var json = afterJsonOpener.Substring(0, + var betweenJsonOpenerAndCloser = afterJsonOpener.Substring(0, afterJsonOpener.IndexOf(jsonCloser, StringComparison.Ordinal)); - if (!json.Contains(docs_templates)) + if (!betweenJsonOpenerAndCloser.Contains(docs_templates)) { document = afterJsonOpener.Substring( afterJsonOpener.IndexOf(jsonCloser, StringComparison.Ordinal) + jsonCloser.Length); - newDocument.Append(beforeJson + json + jsonCloser); + newDocument.Append(beforeJson + betweenJsonOpenerAndCloser + jsonCloser); continue; } - json = json.Substring(json.IndexOf(docs_templates, StringComparison.Ordinal) + docs_templates.Length); + var json = betweenJsonOpenerAndCloser.Substring(betweenJsonOpenerAndCloser.IndexOf(docs_templates, StringComparison.Ordinal) + docs_templates.Length); var templateName = JsonConvert.DeserializeObject(json)?.Name; 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 2572e3bfeb..2c9162d7c5 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 @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Volo.Abp; using Volo.Abp.AspNetCore.Mvc.Localization; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; using Volo.Abp.Domain.Entities; @@ -60,7 +61,7 @@ namespace Volo.Docs.Pages.Documents.Project public DocumentParametersDto DocumentPreferences { get; set; } - public DocumentRenderParameters UserPreferences { get; set; } + public DocumentRenderParameters UserPreferences { get; set; } = new DocumentRenderParameters(); private readonly IDocumentAppService _documentAppService; private readonly IDocumentToHtmlConverterFactory _documentToHtmlConverterFactory; @@ -419,7 +420,6 @@ namespace Volo.Docs.Pages.Documents.Project private async Task> GetDocumentPartialTemplatesAsync() { - var contents = new List(); var projectPartialTemplates = await _documentAppService.GetPartialTemplatesAsync( new GetDocumentPartialTemplatesInput() @@ -431,14 +431,14 @@ namespace Volo.Docs.Pages.Documents.Project if (!projectPartialTemplates?.Templates?.Any() ?? true) { - return new List(); + return null; } var partialTemplatesInDocument = await _documentSectionRenderer.GetPartialTemplatesInDocumentAsync(Document.Content); - if (!partialTemplatesInDocument?.Any() ?? true) + if (!partialTemplatesInDocument?.Any(t => t.Parameters != null) ?? true) { - return new List(); + return null; } foreach (var partialTemplates in partialTemplatesInDocument) @@ -447,11 +447,13 @@ namespace Volo.Docs.Pages.Documents.Project { if (!UserPreferences.ContainsKey(parameter.Key)) { - UserPreferences.Add(parameter.Key, parameter.Value); + UserPreferences.Add(parameter.Key, parameter.Value); } } } + var contents = new List(); + foreach (var partialTemplate in projectPartialTemplates.Templates) { contents.Add(new DocumentPartialTemplateContent @@ -472,10 +474,8 @@ namespace Volo.Docs.Pages.Documents.Project private void SetUserPreferences() { - UserPreferences = new DocumentRenderParameters - { - {"Document_Language_Code", LanguageCode}, {"Document_Version", Version} - }; + UserPreferences.Add("Document_Language_Code", LanguageCode); + UserPreferences.Add("Document_Version", Version); var cookie = Request.Cookies["AbpDocsPreferences"];