@ethlete/contentful 0.1.0-next.9 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/components/audio/contentful-audio.component.mjs +3 -3
- package/esm2020/lib/components/file/contentful-file.component.mjs +3 -3
- package/esm2020/lib/components/image/contentful-image.component.mjs +94 -47
- package/esm2020/lib/components/image/contentful-image.component.utils.mjs +86 -0
- package/esm2020/lib/components/image/index.mjs +2 -0
- package/esm2020/lib/components/image/public-api.mjs +2 -1
- package/esm2020/lib/components/rich-text-renderer/rich-text-renderer.component.mjs +16 -8
- package/esm2020/lib/components/rich-text-renderer/rich-text-renderer.util.mjs +13 -10
- package/esm2020/lib/components/video/contentful-video.component.mjs +3 -3
- package/esm2020/lib/contentful.imports.mjs +9 -0
- package/esm2020/lib/gql/asset.fragments.mjs +2 -3
- package/esm2020/lib/public-api.mjs +2 -2
- package/esm2020/lib/types/contentful.types.mjs +1 -1
- package/esm2020/lib/utils/contentful-config.mjs +6 -1
- package/esm2020/lib/utils/contentful.util.mjs +7 -1
- package/esm2020/lib/utils/index.mjs +2 -0
- package/fesm2015/ethlete-contentful.mjs +277 -155
- package/fesm2015/ethlete-contentful.mjs.map +1 -1
- package/fesm2020/ethlete-contentful.mjs +274 -154
- package/fesm2020/ethlete-contentful.mjs.map +1 -1
- package/lib/components/image/contentful-image.component.d.ts +20 -12
- package/lib/components/image/contentful-image.component.utils.d.ts +16 -0
- package/lib/components/image/index.d.ts +1 -0
- package/lib/components/image/public-api.d.ts +1 -0
- package/lib/components/rich-text-renderer/rich-text-renderer.component.d.ts +1 -1
- package/lib/components/rich-text-renderer/rich-text-renderer.util.d.ts +2 -3
- package/lib/contentful.imports.d.ts +2 -0
- package/lib/public-api.d.ts +1 -1
- package/lib/types/contentful.types.d.ts +29 -6
- package/lib/utils/contentful.util.d.ts +3 -1
- package/lib/utils/index.d.ts +1 -0
- package/package.json +6 -6
- package/esm2020/lib/contentful.module.mjs +0 -40
- package/lib/contentful.module.d.ts +0 -11
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NgIf, NgClass, NgOptimizedImage, DOCUMENT } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { InjectionToken, inject,
|
|
3
|
+
import { InjectionToken, inject, ChangeDetectorRef, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Renderer2, ElementRef, ComponentFactoryResolver, ApplicationRef, Injector } from '@angular/core';
|
|
4
4
|
import { DomPortalOutlet, ComponentPortal } from '@angular/cdk/portal';
|
|
5
|
-
import
|
|
5
|
+
import * as i1 from '@ethlete/cdk';
|
|
6
|
+
import { PictureDataDirective, PictureComponent } from '@ethlete/cdk';
|
|
6
7
|
import { BLOCKS, INLINES } from '@contentful/rich-text-types';
|
|
7
8
|
import { gql } from '@ethlete/query';
|
|
8
9
|
|
|
@@ -17,19 +18,249 @@ const createContentfulConfig = (config = {}) => (Object.assign({
|
|
|
17
18
|
video: ContentfulVideoComponent,
|
|
18
19
|
},
|
|
19
20
|
customComponents: {},
|
|
21
|
+
imageOptions: {
|
|
22
|
+
srcsetSizes: ['375w', '1280w', '1920w', '2560w'],
|
|
23
|
+
sizes: [],
|
|
24
|
+
backgroundColor: null,
|
|
25
|
+
},
|
|
20
26
|
}, (config || {})));
|
|
21
27
|
|
|
22
28
|
const RICH_TEXT_RENDERER_COMPONENT_DATA = new InjectionToken('RICH_TEXT_RENDERER_COMPONENT_DATA');
|
|
23
29
|
|
|
30
|
+
const provideContentfulConfig = (contentfulConfig = {}) => {
|
|
31
|
+
return { provide: CONTENTFUL_CONFIG, useValue: createContentfulConfig(contentfulConfig) };
|
|
32
|
+
};
|
|
33
|
+
const isContentfulImage = (v) => {
|
|
34
|
+
return !!v && 'asset' in v && 'alt' in v && 'resizeBehavior' in v && 'focusArea' in v;
|
|
35
|
+
};
|
|
36
|
+
const isContentfulAsset = (v) => {
|
|
37
|
+
return !!v && 'contentType' in v && 'description' in v && 'height' in v && 'url' in v && 'width' in v;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const generateDefaultContentfulImageSource = (data) => {
|
|
41
|
+
const { url, contentType } = data;
|
|
42
|
+
return {
|
|
43
|
+
type: contentType,
|
|
44
|
+
srcset: url,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Parses source set sizes into an object containing with and height. Eg.
|
|
49
|
+
* - `"400"` - 400px width
|
|
50
|
+
* - `"400x300"` - 400px width and 300px height
|
|
51
|
+
* - `"400w"` - 400px width
|
|
52
|
+
* - `"400h"` - 400px height
|
|
53
|
+
* - `"400wx300h"` - 400px width and 300px height
|
|
54
|
+
**/
|
|
55
|
+
const parseContentfulImageSize = (size) => {
|
|
56
|
+
let width = null;
|
|
57
|
+
let height = null;
|
|
58
|
+
if (size.includes('x')) {
|
|
59
|
+
const [w, h] = size.split('x');
|
|
60
|
+
width = w;
|
|
61
|
+
height = h;
|
|
62
|
+
}
|
|
63
|
+
else if (size.includes('h')) {
|
|
64
|
+
height = size;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
width = size;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
width: width ? parseInt(width, 10) : null,
|
|
71
|
+
height: height ? parseInt(height, 10) : null,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const generateContentfulImageSources = (data, srcsetSizes, backgroundColor) => {
|
|
75
|
+
const assetData = isContentfulImage(data) ? data.asset : data;
|
|
76
|
+
const imageData = isContentfulImage(data) ? data : null;
|
|
77
|
+
if (!assetData) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
80
|
+
const sources = [];
|
|
81
|
+
const SOURCE_TYPES = ['image/avif', 'image/webp', 'image/png', 'image/jpg'];
|
|
82
|
+
for (const type of SOURCE_TYPES) {
|
|
83
|
+
const baseUrl = assetData.url;
|
|
84
|
+
const sourceSets = [];
|
|
85
|
+
const queryParams = [];
|
|
86
|
+
// Set the format (e.g. 'fm=webp')
|
|
87
|
+
queryParams.push(`fm=${type.split('/')[1]}`);
|
|
88
|
+
if (backgroundColor) {
|
|
89
|
+
queryParams.push(`bg=rgb:${backgroundColor}`);
|
|
90
|
+
}
|
|
91
|
+
if (imageData) {
|
|
92
|
+
if (imageData.quality) {
|
|
93
|
+
queryParams.push(`q=${imageData.quality}`);
|
|
94
|
+
}
|
|
95
|
+
if (imageData.focusArea) {
|
|
96
|
+
queryParams.push(`f=${imageData.focusArea}`);
|
|
97
|
+
}
|
|
98
|
+
if (imageData.resizeBehavior) {
|
|
99
|
+
queryParams.push(`fit=${imageData.resizeBehavior}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (srcsetSizes === null || srcsetSizes === void 0 ? void 0 : srcsetSizes.length) {
|
|
103
|
+
const urlWithParams = `${baseUrl}?${queryParams.join('&')}`;
|
|
104
|
+
for (const size of srcsetSizes) {
|
|
105
|
+
const { width, height } = parseContentfulImageSize(size);
|
|
106
|
+
if (width && height) {
|
|
107
|
+
sourceSets.push(`${urlWithParams}&w=${width}&h=${height} ${width}w`);
|
|
108
|
+
}
|
|
109
|
+
else if (width) {
|
|
110
|
+
sourceSets.push(`${urlWithParams}&w=${width} ${width}w`);
|
|
111
|
+
}
|
|
112
|
+
else if (height) {
|
|
113
|
+
sourceSets.push(`${urlWithParams}&h=${height} ${height}h`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
sources.push({
|
|
118
|
+
type,
|
|
119
|
+
srcset: sourceSets.length ? sourceSets.join(', ') : `${baseUrl}?${queryParams.join('&')}`,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return sources;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
class ContentfulImageComponent {
|
|
126
|
+
constructor() {
|
|
127
|
+
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, {
|
|
128
|
+
optional: true,
|
|
129
|
+
});
|
|
130
|
+
this.pictureData = inject(PictureDataDirective);
|
|
131
|
+
this._cdr = inject(ChangeDetectorRef);
|
|
132
|
+
this._data = null;
|
|
133
|
+
this._sizes = [];
|
|
134
|
+
this._srcsetSizes = [];
|
|
135
|
+
this._backgroundColor = null;
|
|
136
|
+
this.sources = [];
|
|
137
|
+
}
|
|
138
|
+
get data() {
|
|
139
|
+
return this._data;
|
|
140
|
+
}
|
|
141
|
+
set data(v) {
|
|
142
|
+
var _a, _b, _c, _d, _e;
|
|
143
|
+
const assetData = isContentfulImage(v) ? v.asset : v;
|
|
144
|
+
const imageData = isContentfulImage(v) ? v : null;
|
|
145
|
+
if (assetData && !assetData.contentType) {
|
|
146
|
+
this._data = null;
|
|
147
|
+
console.warn('The provided asset is invalid', v);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (assetData && !assetData.contentType.startsWith('image/')) {
|
|
151
|
+
throw new Error('The provided asset is not an image');
|
|
152
|
+
}
|
|
153
|
+
this._data = v !== null && v !== void 0 ? v : null;
|
|
154
|
+
this.pictureData.defaultSrc = assetData ? generateDefaultContentfulImageSource(assetData) : null;
|
|
155
|
+
this.pictureData.alt = (_b = (_a = imageData === null || imageData === void 0 ? void 0 : imageData.alt) !== null && _a !== void 0 ? _a : assetData === null || assetData === void 0 ? void 0 : assetData.description) !== null && _b !== void 0 ? _b : null;
|
|
156
|
+
this.pictureData.width = (_c = assetData === null || assetData === void 0 ? void 0 : assetData.width) !== null && _c !== void 0 ? _c : null;
|
|
157
|
+
this.pictureData.height = (_d = assetData === null || assetData === void 0 ? void 0 : assetData.height) !== null && _d !== void 0 ? _d : null;
|
|
158
|
+
this.pictureData.figcaption = (_e = imageData === null || imageData === void 0 ? void 0 : imageData.caption) !== null && _e !== void 0 ? _e : null;
|
|
159
|
+
this.updateSizes();
|
|
160
|
+
}
|
|
161
|
+
get sizes() {
|
|
162
|
+
return this._sizes;
|
|
163
|
+
}
|
|
164
|
+
set sizes(v) {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
this._sizes = v;
|
|
167
|
+
this.pictureData.sizes = (_b = (_a = this.sizes) === null || _a === void 0 ? void 0 : _a.join(', ')) !== null && _b !== void 0 ? _b : null;
|
|
168
|
+
}
|
|
169
|
+
get srcsetSizes() {
|
|
170
|
+
return this._srcsetSizes;
|
|
171
|
+
}
|
|
172
|
+
set srcsetSizes(v) {
|
|
173
|
+
this._srcsetSizes = v;
|
|
174
|
+
this.updateSizes();
|
|
175
|
+
}
|
|
176
|
+
get backgroundColor() {
|
|
177
|
+
return this._backgroundColor;
|
|
178
|
+
}
|
|
179
|
+
set backgroundColor(v) {
|
|
180
|
+
this._backgroundColor = v;
|
|
181
|
+
this.updateSizes();
|
|
182
|
+
}
|
|
183
|
+
ngOnInit() {
|
|
184
|
+
if (this._richTextData && !this.data) {
|
|
185
|
+
this.data = this._richTextData;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
updateSizes() {
|
|
189
|
+
this.sources = this._data ? generateContentfulImageSources(this._data, this.srcsetSizes, this.backgroundColor) : [];
|
|
190
|
+
this._cdr.markForCheck();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
ContentfulImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ContentfulImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
194
|
+
ContentfulImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: ContentfulImageComponent, isStandalone: true, selector: "et-contentful-image", inputs: { data: "data", sizes: "sizes", srcsetSizes: "srcsetSizes", backgroundColor: "backgroundColor" }, host: { classAttribute: "et-contentful-image" }, hostDirectives: [{ directive: i1.PictureDataDirective, inputs: ["imgClass", "imgClass", "hasPriority", "hasPriority", "figureClass", "figureClass", "pictureClass", "pictureClass", "figcaptionClass", "figcaptionClass"] }], ngImport: i0, template: `
|
|
195
|
+
<et-picture
|
|
196
|
+
[imgClass]="pictureData.imgClass"
|
|
197
|
+
[hasPriority]="pictureData.hasPriority"
|
|
198
|
+
[figureClass]="pictureData.figureClass"
|
|
199
|
+
[pictureClass]="pictureData.pictureClass"
|
|
200
|
+
[figcaptionClass]="pictureData.figcaptionClass"
|
|
201
|
+
[defaultSrc]="pictureData.defaultSrc"
|
|
202
|
+
[alt]="pictureData.alt"
|
|
203
|
+
[figcaption]="pictureData.figcaption"
|
|
204
|
+
[width]="pictureData.width"
|
|
205
|
+
[height]="pictureData.height"
|
|
206
|
+
[sizes]="pictureData.sizes"
|
|
207
|
+
[sources]="sources"
|
|
208
|
+
/>
|
|
209
|
+
`, isInline: true, dependencies: [{ kind: "component", type: PictureComponent, selector: "et-picture", inputs: ["sources"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
210
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ContentfulImageComponent, decorators: [{
|
|
211
|
+
type: Component,
|
|
212
|
+
args: [{
|
|
213
|
+
selector: 'et-contentful-image',
|
|
214
|
+
template: `
|
|
215
|
+
<et-picture
|
|
216
|
+
[imgClass]="pictureData.imgClass"
|
|
217
|
+
[hasPriority]="pictureData.hasPriority"
|
|
218
|
+
[figureClass]="pictureData.figureClass"
|
|
219
|
+
[pictureClass]="pictureData.pictureClass"
|
|
220
|
+
[figcaptionClass]="pictureData.figcaptionClass"
|
|
221
|
+
[defaultSrc]="pictureData.defaultSrc"
|
|
222
|
+
[alt]="pictureData.alt"
|
|
223
|
+
[figcaption]="pictureData.figcaption"
|
|
224
|
+
[width]="pictureData.width"
|
|
225
|
+
[height]="pictureData.height"
|
|
226
|
+
[sizes]="pictureData.sizes"
|
|
227
|
+
[sources]="sources"
|
|
228
|
+
/>
|
|
229
|
+
`,
|
|
230
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
231
|
+
encapsulation: ViewEncapsulation.None,
|
|
232
|
+
standalone: true,
|
|
233
|
+
imports: [NgIf, NgClass, NgOptimizedImage, PictureComponent],
|
|
234
|
+
hostDirectives: [
|
|
235
|
+
{
|
|
236
|
+
directive: PictureDataDirective,
|
|
237
|
+
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property
|
|
238
|
+
inputs: ['imgClass', 'hasPriority', 'figureClass', 'pictureClass', 'figcaptionClass'],
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
host: {
|
|
242
|
+
class: 'et-contentful-image',
|
|
243
|
+
},
|
|
244
|
+
}]
|
|
245
|
+
}], propDecorators: { data: [{
|
|
246
|
+
type: Input
|
|
247
|
+
}], sizes: [{
|
|
248
|
+
type: Input
|
|
249
|
+
}], srcsetSizes: [{
|
|
250
|
+
type: Input
|
|
251
|
+
}], backgroundColor: [{
|
|
252
|
+
type: Input
|
|
253
|
+
}] } });
|
|
254
|
+
|
|
24
255
|
const createRenderCommandsFromContentfulRichText = (options) => {
|
|
25
256
|
const { data, config } = options;
|
|
26
257
|
const commands = [];
|
|
27
258
|
const resourceMap = createContentfulResourceMap(data.links);
|
|
28
|
-
createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config
|
|
259
|
+
createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config);
|
|
29
260
|
return commands;
|
|
30
261
|
};
|
|
31
|
-
const createContentfulRenderCommand = (node, parent, resourceMap,
|
|
32
|
-
var _a, _b, _c, _d;
|
|
262
|
+
const createContentfulRenderCommand = (node, parent, resourceMap, config) => {
|
|
263
|
+
var _a, _b, _c, _d, _e;
|
|
33
264
|
const { nodeType, data: nodeData } = node;
|
|
34
265
|
const { children, marks, value } = getContentfulNodeProps(node);
|
|
35
266
|
const command = {
|
|
@@ -37,7 +268,7 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
37
268
|
data: value,
|
|
38
269
|
attributes: Object.assign(Object.assign({}, (marks
|
|
39
270
|
? {
|
|
40
|
-
class: transformContentfulMarks(marks, useTailwindClasses),
|
|
271
|
+
class: transformContentfulMarks(marks, config.useTailwindClasses),
|
|
41
272
|
}
|
|
42
273
|
: {})), (nodeData['uri'] ? { href: nodeData['uri'], target: '_blank' } : {})),
|
|
43
274
|
children: [],
|
|
@@ -51,16 +282,16 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
51
282
|
const isAudio = asset.contentType.startsWith('audio/');
|
|
52
283
|
command.data = asset;
|
|
53
284
|
if (isImage) {
|
|
54
|
-
command.payload =
|
|
285
|
+
command.payload = config.components.image;
|
|
55
286
|
}
|
|
56
287
|
else if (isVideo) {
|
|
57
|
-
command.payload =
|
|
288
|
+
command.payload = config.components.video;
|
|
58
289
|
}
|
|
59
290
|
else if (isAudio) {
|
|
60
|
-
command.payload =
|
|
291
|
+
command.payload = config.components.audio;
|
|
61
292
|
}
|
|
62
293
|
else {
|
|
63
|
-
command.payload =
|
|
294
|
+
command.payload = config.components.file;
|
|
64
295
|
}
|
|
65
296
|
}
|
|
66
297
|
else {
|
|
@@ -71,7 +302,9 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
71
302
|
const entry = (_c = resourceMap.entriesBlock.get(entryId)) !== null && _c !== void 0 ? _c : resourceMap.entriesInline.get(entryId);
|
|
72
303
|
if (entry) {
|
|
73
304
|
const type = (_d = entry === null || entry === void 0 ? void 0 : entry.__typename) !== null && _d !== void 0 ? _d : 'ET_UNKNOWN';
|
|
74
|
-
|
|
305
|
+
// "Image" is a special wrapper content model for contentful assets.
|
|
306
|
+
// It must be created by the user.
|
|
307
|
+
const component = type === 'Image' ? ContentfulImageComponent : (_e = config.customComponents) === null || _e === void 0 ? void 0 : _e[type];
|
|
75
308
|
if (component) {
|
|
76
309
|
command.payload = component;
|
|
77
310
|
command.data = entry;
|
|
@@ -86,7 +319,7 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
86
319
|
}
|
|
87
320
|
if (children && (children.length !== 1 || children[0].nodeType !== 'text')) {
|
|
88
321
|
children.forEach((child) => {
|
|
89
|
-
createContentfulRenderCommand(child, command, resourceMap,
|
|
322
|
+
createContentfulRenderCommand(child, command, resourceMap, config);
|
|
90
323
|
});
|
|
91
324
|
}
|
|
92
325
|
parent.children.push(command);
|
|
@@ -214,7 +447,6 @@ class ContentfulRichTextRendererComponent {
|
|
|
214
447
|
this._richText = null;
|
|
215
448
|
this._renderer = inject(Renderer2);
|
|
216
449
|
this._elementRef = inject(ElementRef);
|
|
217
|
-
this._viewContainerRef = inject(ViewContainerRef);
|
|
218
450
|
this._componentFactoryResolver = inject(ComponentFactoryResolver);
|
|
219
451
|
this._document = inject(DOCUMENT);
|
|
220
452
|
this._appRef = inject(ApplicationRef);
|
|
@@ -226,15 +458,18 @@ class ContentfulRichTextRendererComponent {
|
|
|
226
458
|
}
|
|
227
459
|
set richText(v) {
|
|
228
460
|
this._richText = v !== null && v !== void 0 ? v : null;
|
|
461
|
+
this.resetAndRender();
|
|
462
|
+
}
|
|
463
|
+
resetAndRender() {
|
|
229
464
|
// clear childNodes to prevent appending new richtext elements to existing one
|
|
230
465
|
const childElements = this._elementRef.nativeElement.childNodes;
|
|
231
466
|
for (const child of childElements) {
|
|
232
467
|
this._renderer.removeChild(this._elementRef.nativeElement, child);
|
|
233
468
|
}
|
|
234
|
-
if (!
|
|
469
|
+
if (!this._richText) {
|
|
235
470
|
return;
|
|
236
471
|
}
|
|
237
|
-
const commands = createRenderCommandsFromContentfulRichText({ data:
|
|
472
|
+
const commands = createRenderCommandsFromContentfulRichText({ data: this._richText, config: this._config });
|
|
238
473
|
this._render(commands);
|
|
239
474
|
}
|
|
240
475
|
_render(commands) {
|
|
@@ -278,6 +513,11 @@ class ContentfulRichTextRendererComponent {
|
|
|
278
513
|
const portal = new DomPortalOutlet(parent, this._componentFactoryResolver, this._appRef, injector, this._document);
|
|
279
514
|
const comp = new ComponentPortal(command.payload);
|
|
280
515
|
const ref = comp.attach(portal);
|
|
516
|
+
if (ref.instance instanceof ContentfulImageComponent) {
|
|
517
|
+
ref.instance.sizes = this._config.imageOptions.sizes;
|
|
518
|
+
ref.instance.srcsetSizes = this._config.imageOptions.srcsetSizes;
|
|
519
|
+
ref.instance.backgroundColor = this._config.imageOptions.backgroundColor;
|
|
520
|
+
}
|
|
281
521
|
element = ref.location.nativeElement;
|
|
282
522
|
}
|
|
283
523
|
}
|
|
@@ -287,9 +527,9 @@ class ContentfulRichTextRendererComponent {
|
|
|
287
527
|
}
|
|
288
528
|
}
|
|
289
529
|
}
|
|
290
|
-
ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
291
|
-
ContentfulRichTextRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
292
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
530
|
+
ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ContentfulRichTextRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
531
|
+
ContentfulRichTextRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: ContentfulRichTextRendererComponent, isStandalone: true, selector: "et-contentful-rich-text-renderer", inputs: { richText: "richText" }, host: { classAttribute: "et-contentful-rich-text-renderer" }, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
532
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ContentfulRichTextRendererComponent, decorators: [{
|
|
293
533
|
type: Component,
|
|
294
534
|
args: [{
|
|
295
535
|
selector: 'et-contentful-rich-text-renderer',
|
|
@@ -333,14 +573,14 @@ class ContentfulAudioComponent {
|
|
|
333
573
|
}
|
|
334
574
|
}
|
|
335
575
|
}
|
|
336
|
-
ContentfulAudioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
337
|
-
ContentfulAudioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
576
|
+
ContentfulAudioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ContentfulAudioComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
577
|
+
ContentfulAudioComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: ContentfulAudioComponent, isStandalone: true, selector: "et-contentful-audio", inputs: { data: "data", audioClass: "audioClass", figureClass: "figureClass", figcaptionClass: "figcaptionClass" }, ngImport: i0, template: `
|
|
338
578
|
<figure *ngIf="data" [ngClass]="figureClass">
|
|
339
579
|
<figcaption [ngClass]="figcaptionClass">{{ data.title }}</figcaption>
|
|
340
580
|
<audio [ngClass]="audioClass" controls src="{{ data.url }}"></audio>
|
|
341
581
|
</figure>
|
|
342
582
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
343
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
583
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ContentfulAudioComponent, decorators: [{
|
|
344
584
|
type: Component,
|
|
345
585
|
args: [{
|
|
346
586
|
selector: 'et-contentful-audio',
|
|
@@ -388,13 +628,13 @@ class ContentfulFileComponent {
|
|
|
388
628
|
}
|
|
389
629
|
}
|
|
390
630
|
}
|
|
391
|
-
ContentfulFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
392
|
-
ContentfulFileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
631
|
+
ContentfulFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ContentfulFileComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
632
|
+
ContentfulFileComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: ContentfulFileComponent, isStandalone: true, selector: "et-contentful-file", inputs: { data: "data", fileClass: "fileClass" }, ngImport: i0, template: `
|
|
393
633
|
<a *ngIf="data" [href]="data.url" [ngClass]="fileClass" class="underline" target="_blank">
|
|
394
634
|
{{ data.title }} ({{ data.size }} Bytes)
|
|
395
635
|
</a>
|
|
396
636
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
397
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
637
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ContentfulFileComponent, decorators: [{
|
|
398
638
|
type: Component,
|
|
399
639
|
args: [{
|
|
400
640
|
selector: 'et-contentful-file',
|
|
@@ -414,90 +654,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
|
|
|
414
654
|
type: Input
|
|
415
655
|
}] } });
|
|
416
656
|
|
|
417
|
-
class ContentfulImageComponent {
|
|
418
|
-
constructor() {
|
|
419
|
-
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
|
|
420
|
-
this._data = null;
|
|
421
|
-
this.imgClass = null;
|
|
422
|
-
this.pictureClass = null;
|
|
423
|
-
this._priority = false;
|
|
424
|
-
}
|
|
425
|
-
get data() {
|
|
426
|
-
return this._data;
|
|
427
|
-
}
|
|
428
|
-
set data(v) {
|
|
429
|
-
if (v && !v.contentType) {
|
|
430
|
-
this._data = null;
|
|
431
|
-
console.warn('The provided asset is invalid', v);
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
if (v && !v.contentType.startsWith('image/')) {
|
|
435
|
-
throw new Error('The provided asset is not an image');
|
|
436
|
-
}
|
|
437
|
-
this._data = v !== null && v !== void 0 ? v : null;
|
|
438
|
-
}
|
|
439
|
-
get priority() {
|
|
440
|
-
return this._priority;
|
|
441
|
-
}
|
|
442
|
-
set priority(value) {
|
|
443
|
-
this._priority = coerceBooleanProperty(value);
|
|
444
|
-
}
|
|
445
|
-
ngOnInit() {
|
|
446
|
-
if (this._richTextData && !this.data) {
|
|
447
|
-
this.data = this._richTextData;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
ContentfulImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
452
|
-
ContentfulImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.2", type: ContentfulImageComponent, isStandalone: true, selector: "et-contentful-image", inputs: { data: "data", imgClass: "imgClass", pictureClass: "pictureClass", priority: "priority" }, ngImport: i0, template: `
|
|
453
|
-
<picture *ngIf="data" [ngClass]="pictureClass">
|
|
454
|
-
<source srcset="{{ data.url }}?fm=avif" type="image/avif" />
|
|
455
|
-
<source srcset="{{ data.url }}?fm=webp" type="image/webp" />
|
|
456
|
-
<source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
|
|
457
|
-
<img
|
|
458
|
-
[attr.alt]="data.description ?? undefined"
|
|
459
|
-
[width]="data.width ?? undefined"
|
|
460
|
-
[height]="data.height ?? undefined"
|
|
461
|
-
[priority]="data.priority ?? priority"
|
|
462
|
-
[ngClass]="imgClass"
|
|
463
|
-
ngSrc="{{ data.url }}"
|
|
464
|
-
/>
|
|
465
|
-
</picture>
|
|
466
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgOptimizedImage, selector: "img[ngSrc]", inputs: ["ngSrc", "ngSrcset", "sizes", "width", "height", "loading", "priority", "disableOptimizedSrcset", "fill", "src", "srcset"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
467
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulImageComponent, decorators: [{
|
|
468
|
-
type: Component,
|
|
469
|
-
args: [{
|
|
470
|
-
selector: 'et-contentful-image',
|
|
471
|
-
template: `
|
|
472
|
-
<picture *ngIf="data" [ngClass]="pictureClass">
|
|
473
|
-
<source srcset="{{ data.url }}?fm=avif" type="image/avif" />
|
|
474
|
-
<source srcset="{{ data.url }}?fm=webp" type="image/webp" />
|
|
475
|
-
<source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
|
|
476
|
-
<img
|
|
477
|
-
[attr.alt]="data.description ?? undefined"
|
|
478
|
-
[width]="data.width ?? undefined"
|
|
479
|
-
[height]="data.height ?? undefined"
|
|
480
|
-
[priority]="data.priority ?? priority"
|
|
481
|
-
[ngClass]="imgClass"
|
|
482
|
-
ngSrc="{{ data.url }}"
|
|
483
|
-
/>
|
|
484
|
-
</picture>
|
|
485
|
-
`,
|
|
486
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
487
|
-
encapsulation: ViewEncapsulation.None,
|
|
488
|
-
standalone: true,
|
|
489
|
-
imports: [NgIf, NgClass, NgOptimizedImage],
|
|
490
|
-
}]
|
|
491
|
-
}], propDecorators: { data: [{
|
|
492
|
-
type: Input
|
|
493
|
-
}], imgClass: [{
|
|
494
|
-
type: Input
|
|
495
|
-
}], pictureClass: [{
|
|
496
|
-
type: Input
|
|
497
|
-
}], priority: [{
|
|
498
|
-
type: Input
|
|
499
|
-
}] } });
|
|
500
|
-
|
|
501
657
|
class ContentfulVideoComponent {
|
|
502
658
|
constructor() {
|
|
503
659
|
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
|
|
@@ -524,13 +680,13 @@ class ContentfulVideoComponent {
|
|
|
524
680
|
}
|
|
525
681
|
}
|
|
526
682
|
}
|
|
527
|
-
ContentfulVideoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
528
|
-
ContentfulVideoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
683
|
+
ContentfulVideoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ContentfulVideoComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
684
|
+
ContentfulVideoComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: ContentfulVideoComponent, isStandalone: true, selector: "et-contentful-video", inputs: { data: "data", videoClass: "videoClass" }, ngImport: i0, template: `
|
|
529
685
|
<video *ngIf="data" [ngClass]="videoClass" controls>
|
|
530
686
|
<source src="{{ data.url }}" type="{{ data.contentType }}" />
|
|
531
687
|
</video>
|
|
532
688
|
`, isInline: true, dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
533
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
689
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ContentfulVideoComponent, decorators: [{
|
|
534
690
|
type: Component,
|
|
535
691
|
args: [{
|
|
536
692
|
selector: 'et-contentful-video',
|
|
@@ -550,42 +706,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
|
|
|
550
706
|
type: Input
|
|
551
707
|
}] } });
|
|
552
708
|
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
ContentfulRichTextRendererComponent], exports: [ContentfulAudioComponent,
|
|
561
|
-
ContentfulFileComponent,
|
|
562
|
-
ContentfulImageComponent,
|
|
563
|
-
ContentfulVideoComponent,
|
|
564
|
-
ContentfulRichTextRendererComponent] });
|
|
565
|
-
ContentfulModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
|
|
566
|
-
ContentfulFileComponent,
|
|
567
|
-
ContentfulImageComponent,
|
|
568
|
-
ContentfulVideoComponent,
|
|
569
|
-
ContentfulRichTextRendererComponent] });
|
|
570
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulModule, decorators: [{
|
|
571
|
-
type: NgModule,
|
|
572
|
-
args: [{
|
|
573
|
-
imports: [
|
|
574
|
-
ContentfulAudioComponent,
|
|
575
|
-
ContentfulFileComponent,
|
|
576
|
-
ContentfulImageComponent,
|
|
577
|
-
ContentfulVideoComponent,
|
|
578
|
-
ContentfulRichTextRendererComponent,
|
|
579
|
-
],
|
|
580
|
-
exports: [
|
|
581
|
-
ContentfulAudioComponent,
|
|
582
|
-
ContentfulFileComponent,
|
|
583
|
-
ContentfulImageComponent,
|
|
584
|
-
ContentfulVideoComponent,
|
|
585
|
-
ContentfulRichTextRendererComponent,
|
|
586
|
-
],
|
|
587
|
-
}]
|
|
588
|
-
}] });
|
|
709
|
+
const ContentfulImports = [
|
|
710
|
+
ContentfulAudioComponent,
|
|
711
|
+
ContentfulFileComponent,
|
|
712
|
+
ContentfulImageComponent,
|
|
713
|
+
ContentfulVideoComponent,
|
|
714
|
+
ContentfulRichTextRendererComponent,
|
|
715
|
+
];
|
|
589
716
|
|
|
590
717
|
const GQL_FRAGMENT_CONTENTFUL_ASSET = gql `
|
|
591
718
|
fragment AssetData on Asset {
|
|
@@ -609,23 +736,18 @@ const GQL_FRAGMENT_CONTENTFUL_IMAGE = gql `
|
|
|
609
736
|
asset {
|
|
610
737
|
...AssetData
|
|
611
738
|
}
|
|
612
|
-
sizes
|
|
613
739
|
alt
|
|
614
740
|
caption
|
|
615
741
|
resizeBehavior
|
|
616
742
|
focusArea
|
|
617
743
|
quality
|
|
618
|
-
|
|
744
|
+
__typename
|
|
619
745
|
}
|
|
620
746
|
`;
|
|
621
747
|
|
|
622
|
-
const provideContentfulConfig = (contentfulConfig = {}) => {
|
|
623
|
-
return { provide: CONTENTFUL_CONFIG, useValue: createContentfulConfig(contentfulConfig) };
|
|
624
|
-
};
|
|
625
|
-
|
|
626
748
|
/**
|
|
627
749
|
* Generated bundle index. Do not edit.
|
|
628
750
|
*/
|
|
629
751
|
|
|
630
|
-
export { CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulFileComponent, ContentfulImageComponent,
|
|
752
|
+
export { CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulFileComponent, ContentfulImageComponent, ContentfulImports, ContentfulRichTextRendererComponent, ContentfulVideoComponent, GQL_FRAGMENT_CONTENTFUL_ASSET, GQL_FRAGMENT_CONTENTFUL_IMAGE, RICH_TEXT_RENDERER_COMPONENT_DATA, createContentfulConfig, createContentfulMap, createContentfulRenderCommand, createContentfulResourceMap, createRenderCommandsFromContentfulRichText, generateContentfulImageSources, generateDefaultContentfulImageSource, getContentfulNodeProps, isContentfulAsset, isContentfulImage, parseContentfulImageSize, provideContentfulConfig, transformContentfulMarks, translateContentfulNodeTypeToHtmlTag };
|
|
631
753
|
//# sourceMappingURL=ethlete-contentful.mjs.map
|