diff --git a/Apps.Contentful/Actions/EntryActions.cs b/Apps.Contentful/Actions/EntryActions.cs index 64fda3e..b8de9cb 100644 --- a/Apps.Contentful/Actions/EntryActions.cs +++ b/Apps.Contentful/Actions/EntryActions.cs @@ -318,7 +318,10 @@ public async Task 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; diff --git a/Apps.Contentful/Apps.Contentful.csproj b/Apps.Contentful/Apps.Contentful.csproj index 8c4f621..4ce9523 100644 --- a/Apps.Contentful/Apps.Contentful.csproj +++ b/Apps.Contentful/Apps.Contentful.csproj @@ -6,7 +6,7 @@ enable Contentful The headless content management system - 1.8.12 + 1.8.13 Apps.Contentful diff --git a/Apps.Contentful/HtmlHelpers/EntryToHtmlConverter.cs b/Apps.Contentful/HtmlHelpers/EntryToHtmlConverter.cs index d52d5c6..0344e66 100644 --- a/Apps.Contentful/HtmlHelpers/EntryToHtmlConverter.cs +++ b/Apps.Contentful/HtmlHelpers/EntryToHtmlConverter.cs @@ -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 entriesContent, string locale, string defaultLocale, string spaceId, string entryTitle, string entryAdminUrl, User updatedBy) { @@ -260,6 +263,18 @@ private string ConvertCustomFieldToHtml(JToken quoteToken) if (linkType == "Asset") { + if (!includeReferencedAssets) + { + var assetAttributes = new Dictionary + { + { "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; @@ -542,4 +557,4 @@ private void AddBlackbirdMeta(HtmlDocument htmlDoc, HtmlNode headNode, string na return (htmlDoc, bodyNode); } -} \ No newline at end of file +} diff --git a/Apps.Contentful/Models/Requests/GetEntryAsHtmlRequest.cs b/Apps.Contentful/Models/Requests/GetEntryAsHtmlRequest.cs index d6514d6..d8a885a 100644 --- a/Apps.Contentful/Models/Requests/GetEntryAsHtmlRequest.cs +++ b/Apps.Contentful/Models/Requests/GetEntryAsHtmlRequest.cs @@ -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? IgnoredFieldIds { get; set; } @@ -33,4 +36,4 @@ public class GetEntryAsHtmlRequest [Display("Exclude tags for referenced entries"), DataSource(typeof(ListEntriesTagDataHandler))] public IEnumerable? ExcludeTags { get; set; } -} \ No newline at end of file +}