Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Apps.Contentful/Actions/EntryActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ public async Task<DownloadContentOutput> GetEntryLocalizableFieldsAsHtmlFile(
entryIdentifier.ContentId,
input.MaxDepth, 0, errors);

var htmlConverter = new EntryToHtmlConverter(InvocationContext, entryIdentifier.Environment);
var htmlConverter = new EntryToHtmlConverter(
InvocationContext,
entryIdentifier.Environment,
input.IncludeReferencedAssets ?? true);

FileReference file;
string fileNameFirstPart = entryIdentifier.ContentId;
Expand Down
2 changes: 1 addition & 1 deletion Apps.Contentful/Apps.Contentful.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Nullable>enable</Nullable>
<Product>Contentful</Product>
<Description>The headless content management system</Description>
<Version>1.8.12</Version>
<Version>1.8.13</Version>
<AssemblyName>Apps.Contentful</AssemblyName>
</PropertyGroup>

Expand Down
19 changes: 17 additions & 2 deletions Apps.Contentful/HtmlHelpers/EntryToHtmlConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

namespace Apps.Contentful.HtmlHelpers;

public class EntryToHtmlConverter(InvocationContext invocationContext, string? environment)
public class EntryToHtmlConverter(
InvocationContext invocationContext,
string? environment,
bool includeReferencedAssets = true)
{
public string ToHtml(List<EntryContentDto> entriesContent, string locale, string defaultLocale, string spaceId, string entryTitle, string entryAdminUrl, User updatedBy)
{
Expand Down Expand Up @@ -260,6 +263,18 @@ private string ConvertCustomFieldToHtml(JToken quoteToken)

if (linkType == "Asset")
{
if (!includeReferencedAssets)
{
var assetAttributes = new Dictionary<string, string>
{
{ "data-contentful-link-type", linkType! },
{ "data-contentful-link-id", linkId! },
{ "data-contentful-localized", field.Localized.ToString() }
};

return WrapFieldInDiv(doc, entryId, field, additionalAttributes: assetAttributes);
}

var client = new ContentfulClient(invocationContext.AuthenticationCredentialsProviders, environment);
ManagementAsset? asset = null;

Expand Down Expand Up @@ -542,4 +557,4 @@ private void AddBlackbirdMeta(HtmlDocument htmlDoc, HtmlNode headNode, string na

return (htmlDoc, bodyNode);
}
}
}
5 changes: 4 additions & 1 deletion Apps.Contentful/Models/Requests/GetEntryAsHtmlRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class GetEntryAsHtmlRequest
[Display("Include embedded block entries", Description = "Recursively include content of entries that are referenced as embedded block entries in 'Rich text' fields")]
public bool? GetEmbeddedBlockContent { get; set; }

[Display("Include referenced assets", Description = "Include asset content referenced from entry fields")]
public bool? IncludeReferencedAssets { get; set; } = true;

[Display("Exclude field IDs", Description = "All field IDs in this collection will be omitted from the exported content")]
public IEnumerable<string>? IgnoredFieldIds { get; set; }

Expand All @@ -33,4 +36,4 @@ public class GetEntryAsHtmlRequest

[Display("Exclude tags for referenced entries"), DataSource(typeof(ListEntriesTagDataHandler))]
public IEnumerable<string>? ExcludeTags { get; set; }
}
}