Skip to content

Commit 18e2d04

Browse files
authored
Merge pull request #22899 from abpframework/liangshiwei/docs-patch
Improve PDF file generation
2 parents cb7462b + c731847 commit 18e2d04

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ public override void ConfigureServices(ServiceConfigurationContext context)
177177

178178
Configure<DocsProjectPdfGeneratorOptions>(options =>
179179
{
180-
options.BaseUrl = configuration["App:selfUrl"];
181-
options.IndexPagePath = "Index.md";
180+
options.BaseUrl = configuration["App:SelfUrl"];
181+
options.IndexPagePath = "index.md";
182182
options.CalculatePdfFileTitle = project => project.ShortName == "abp" ? "ABP Documentation" : null;
183183
options.DocumentContentNormalizer = content => content.Replace("<i class=\"fa fa-minus text-secondary\"></i>", "No").Replace("<i class=\"fa fa-check text-success\"></i>", "Yes");
184184
});

modules/docs/app/VoloDocs.Web/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"App": {
3-
"selfUrl": "https://localhost:5001"
3+
"SelfUrl": "https://localhost:5001"
44
},
55
"Kestrel": {
66
"EndPoints": {

modules/docs/src/Volo.Docs.Domain/Volo/Docs/Projects/Pdf/ProjectPdfGenerator.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,19 +326,21 @@ private async Task<Document> GetDocumentAsync(
326326
version = string.IsNullOrWhiteSpace(version) ? project.LatestVersionBranchName : version;
327327

328328
Document document = null;
329-
330329
Exception firstException = null;
331-
foreach (var name in GetPossibleNames(documentName, project.Format))
330+
331+
var possibleNames = GetPossibleNames(documentName, project.Format);
332+
document = await DocumentRepository.FindAsync(project.Id, possibleNames, languageCode, version);
333+
if (document != null)
334+
{
335+
return document;
336+
}
337+
338+
foreach (var name in possibleNames)
332339
{
333340
try
334341
{
335-
document = await DocumentRepository.FindAsync(project.Id, documentName, version, languageCode);
336-
if (document != null)
337-
{
338-
break;
339-
}
340-
341342
document = await DocumentSource.GetDocumentAsync(project, name, languageCode, version);
343+
await DocumentRepository.InsertAsync(document, true);
342344
break;
343345
}
344346
catch (Exception ex)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
@if (Model.HasDownloadPdfPermission)
295295
{
296296
<div class="docs-sidebar-footer">
297-
<a href="@Url.Content($"~/api/docs/documents/pdf?ProjectId={Model.Project.Id}&Version={(Model.LatestVersionInfo == null || Model.LatestVersionInfo.IsSelected ? DocsAppConsts.Latest : Model.Version)}&LanguageCode={Model.LanguageCode}")" target="_blank" class="download-pdf-btn">
297+
<a href="@Url.Content($"~/api/docs/documents/pdf?ProjectId={Model.Project.Id}&Version={(Model.LatestVersionInfo.IsSelected ? Model.LatestVersionInfo.Version : Model.Version)}&LanguageCode={Model.LanguageCode ?? Model.DefaultLanguageCode}")" target="_blank" class="download-pdf-btn">
298298
<i class="fa fa-download"></i> @L["DownloadPDF"]
299299
</a>
300300
</div>

0 commit comments

Comments
 (0)