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