@ethlete/contentful 0.1.0-next.8 → 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 +32 -0
- package/esm2020/lib/gql/public-api.mjs +2 -0
- package/esm2020/lib/public-api.mjs +3 -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 +307 -152
- package/fesm2015/ethlete-contentful.mjs.map +1 -1
- package/fesm2020/ethlete-contentful.mjs +304 -151
- 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/gql/asset.fragments.d.ts +2 -0
- package/lib/gql/public-api.d.ts +1 -0
- package/lib/public-api.d.ts +2 -1
- package/lib/types/contentful.types.d.ts +41 -2
- package/lib/utils/contentful.util.d.ts +3 -1
- package/lib/utils/index.d.ts +1 -0
- package/package.json +3 -2
- package/esm2020/lib/contentful.module.mjs +0 -40
- package/lib/contentful.module.d.ts +0 -11
|
@@ -1,9 +1,11 @@
|
|
|
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';
|
|
8
|
+
import { gql } from '@ethlete/query';
|
|
7
9
|
|
|
8
10
|
const CONTENTFUL_CONFIG = new InjectionToken('ContentfulConfig');
|
|
9
11
|
|
|
@@ -18,20 +20,248 @@ const createContentfulConfig = (config = {}) => ({
|
|
|
18
20
|
video: ContentfulVideoComponent,
|
|
19
21
|
},
|
|
20
22
|
customComponents: {},
|
|
23
|
+
imageOptions: {
|
|
24
|
+
srcsetSizes: ['375w', '1280w', '1920w', '2560w'],
|
|
25
|
+
sizes: [],
|
|
26
|
+
backgroundColor: null,
|
|
27
|
+
},
|
|
21
28
|
},
|
|
22
29
|
...(config || {}),
|
|
23
30
|
});
|
|
24
31
|
|
|
25
32
|
const RICH_TEXT_RENDERER_COMPONENT_DATA = new InjectionToken('RICH_TEXT_RENDERER_COMPONENT_DATA');
|
|
26
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
|
+
|
|
27
257
|
const createRenderCommandsFromContentfulRichText = (options) => {
|
|
28
258
|
const { data, config } = options;
|
|
29
259
|
const commands = [];
|
|
30
260
|
const resourceMap = createContentfulResourceMap(data.links);
|
|
31
|
-
createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config
|
|
261
|
+
createContentfulRenderCommand(data.json, { children: commands, payload: data.json.nodeType }, resourceMap, config);
|
|
32
262
|
return commands;
|
|
33
263
|
};
|
|
34
|
-
const createContentfulRenderCommand = (node, parent, resourceMap,
|
|
264
|
+
const createContentfulRenderCommand = (node, parent, resourceMap, config) => {
|
|
35
265
|
const { nodeType, data: nodeData } = node;
|
|
36
266
|
const { children, marks, value } = getContentfulNodeProps(node);
|
|
37
267
|
const command = {
|
|
@@ -40,7 +270,7 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
40
270
|
attributes: {
|
|
41
271
|
...(marks
|
|
42
272
|
? {
|
|
43
|
-
class: transformContentfulMarks(marks, useTailwindClasses),
|
|
273
|
+
class: transformContentfulMarks(marks, config.useTailwindClasses),
|
|
44
274
|
}
|
|
45
275
|
: {}),
|
|
46
276
|
...(nodeData['uri'] ? { href: nodeData['uri'], target: '_blank' } : {}),
|
|
@@ -56,16 +286,16 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
56
286
|
const isAudio = asset.contentType.startsWith('audio/');
|
|
57
287
|
command.data = asset;
|
|
58
288
|
if (isImage) {
|
|
59
|
-
command.payload =
|
|
289
|
+
command.payload = config.components.image;
|
|
60
290
|
}
|
|
61
291
|
else if (isVideo) {
|
|
62
|
-
command.payload =
|
|
292
|
+
command.payload = config.components.video;
|
|
63
293
|
}
|
|
64
294
|
else if (isAudio) {
|
|
65
|
-
command.payload =
|
|
295
|
+
command.payload = config.components.audio;
|
|
66
296
|
}
|
|
67
297
|
else {
|
|
68
|
-
command.payload =
|
|
298
|
+
command.payload = config.components.file;
|
|
69
299
|
}
|
|
70
300
|
}
|
|
71
301
|
else {
|
|
@@ -76,7 +306,9 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
76
306
|
const entry = resourceMap.entriesBlock.get(entryId) ?? resourceMap.entriesInline.get(entryId);
|
|
77
307
|
if (entry) {
|
|
78
308
|
const type = entry?.__typename ?? 'ET_UNKNOWN';
|
|
79
|
-
|
|
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];
|
|
80
312
|
if (component) {
|
|
81
313
|
command.payload = component;
|
|
82
314
|
command.data = entry;
|
|
@@ -91,7 +323,7 @@ const createContentfulRenderCommand = (node, parent, resourceMap, useTailwindCla
|
|
|
91
323
|
}
|
|
92
324
|
if (children && (children.length !== 1 || children[0].nodeType !== 'text')) {
|
|
93
325
|
children.forEach((child) => {
|
|
94
|
-
createContentfulRenderCommand(child, command, resourceMap,
|
|
326
|
+
createContentfulRenderCommand(child, command, resourceMap, config);
|
|
95
327
|
});
|
|
96
328
|
}
|
|
97
329
|
parent.children.push(command);
|
|
@@ -215,7 +447,6 @@ class ContentfulRichTextRendererComponent {
|
|
|
215
447
|
this._richText = null;
|
|
216
448
|
this._renderer = inject(Renderer2);
|
|
217
449
|
this._elementRef = inject(ElementRef);
|
|
218
|
-
this._viewContainerRef = inject(ViewContainerRef);
|
|
219
450
|
this._componentFactoryResolver = inject(ComponentFactoryResolver);
|
|
220
451
|
this._document = inject(DOCUMENT);
|
|
221
452
|
this._appRef = inject(ApplicationRef);
|
|
@@ -227,15 +458,18 @@ class ContentfulRichTextRendererComponent {
|
|
|
227
458
|
}
|
|
228
459
|
set richText(v) {
|
|
229
460
|
this._richText = v ?? null;
|
|
461
|
+
this.resetAndRender();
|
|
462
|
+
}
|
|
463
|
+
resetAndRender() {
|
|
230
464
|
// clear childNodes to prevent appending new richtext elements to existing one
|
|
231
465
|
const childElements = this._elementRef.nativeElement.childNodes;
|
|
232
466
|
for (const child of childElements) {
|
|
233
467
|
this._renderer.removeChild(this._elementRef.nativeElement, child);
|
|
234
468
|
}
|
|
235
|
-
if (!
|
|
469
|
+
if (!this._richText) {
|
|
236
470
|
return;
|
|
237
471
|
}
|
|
238
|
-
const commands = createRenderCommandsFromContentfulRichText({ data:
|
|
472
|
+
const commands = createRenderCommandsFromContentfulRichText({ data: this._richText, config: this._config });
|
|
239
473
|
this._render(commands);
|
|
240
474
|
}
|
|
241
475
|
_render(commands) {
|
|
@@ -279,6 +513,11 @@ class ContentfulRichTextRendererComponent {
|
|
|
279
513
|
const portal = new DomPortalOutlet(parent, this._componentFactoryResolver, this._appRef, injector, this._document);
|
|
280
514
|
const comp = new ComponentPortal(command.payload);
|
|
281
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
|
+
}
|
|
282
521
|
element = ref.location.nativeElement;
|
|
283
522
|
}
|
|
284
523
|
}
|
|
@@ -288,9 +527,9 @@ class ContentfulRichTextRendererComponent {
|
|
|
288
527
|
}
|
|
289
528
|
}
|
|
290
529
|
}
|
|
291
|
-
ContentfulRichTextRendererComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
292
|
-
ContentfulRichTextRendererComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.
|
|
293
|
-
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: [{
|
|
294
533
|
type: Component,
|
|
295
534
|
args: [{
|
|
296
535
|
selector: 'et-contentful-rich-text-renderer',
|
|
@@ -334,14 +573,14 @@ class ContentfulAudioComponent {
|
|
|
334
573
|
}
|
|
335
574
|
}
|
|
336
575
|
}
|
|
337
|
-
ContentfulAudioComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
338
|
-
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: `
|
|
339
578
|
<figure *ngIf="data" [ngClass]="figureClass">
|
|
340
579
|
<figcaption [ngClass]="figcaptionClass">{{ data.title }}</figcaption>
|
|
341
580
|
<audio [ngClass]="audioClass" controls src="{{ data.url }}"></audio>
|
|
342
581
|
</figure>
|
|
343
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 });
|
|
344
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
583
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulAudioComponent, decorators: [{
|
|
345
584
|
type: Component,
|
|
346
585
|
args: [{
|
|
347
586
|
selector: 'et-contentful-audio',
|
|
@@ -389,13 +628,13 @@ class ContentfulFileComponent {
|
|
|
389
628
|
}
|
|
390
629
|
}
|
|
391
630
|
}
|
|
392
|
-
ContentfulFileComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
393
|
-
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: `
|
|
394
633
|
<a *ngIf="data" [href]="data.url" [ngClass]="fileClass" class="underline" target="_blank">
|
|
395
634
|
{{ data.title }} ({{ data.size }} Bytes)
|
|
396
635
|
</a>
|
|
397
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 });
|
|
398
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
637
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulFileComponent, decorators: [{
|
|
399
638
|
type: Component,
|
|
400
639
|
args: [{
|
|
401
640
|
selector: 'et-contentful-file',
|
|
@@ -415,90 +654,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
|
|
|
415
654
|
type: Input
|
|
416
655
|
}] } });
|
|
417
656
|
|
|
418
|
-
class ContentfulImageComponent {
|
|
419
|
-
constructor() {
|
|
420
|
-
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
|
|
421
|
-
this._data = null;
|
|
422
|
-
this.imgClass = null;
|
|
423
|
-
this.pictureClass = null;
|
|
424
|
-
this._priority = false;
|
|
425
|
-
}
|
|
426
|
-
get data() {
|
|
427
|
-
return this._data;
|
|
428
|
-
}
|
|
429
|
-
set data(v) {
|
|
430
|
-
if (v && !v.contentType) {
|
|
431
|
-
this._data = null;
|
|
432
|
-
console.warn('The provided asset is invalid', v);
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
if (v && !v.contentType.startsWith('image/')) {
|
|
436
|
-
throw new Error('The provided asset is not an image');
|
|
437
|
-
}
|
|
438
|
-
this._data = v ?? null;
|
|
439
|
-
}
|
|
440
|
-
get priority() {
|
|
441
|
-
return this._priority;
|
|
442
|
-
}
|
|
443
|
-
set priority(value) {
|
|
444
|
-
this._priority = coerceBooleanProperty(value);
|
|
445
|
-
}
|
|
446
|
-
ngOnInit() {
|
|
447
|
-
if (this._richTextData && !this.data) {
|
|
448
|
-
this.data = this._richTextData;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
ContentfulImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
453
|
-
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: `
|
|
454
|
-
<picture *ngIf="data" [ngClass]="pictureClass">
|
|
455
|
-
<source srcset="{{ data.url }}?fm=avif" type="image/avif" />
|
|
456
|
-
<source srcset="{{ data.url }}?fm=webp" type="image/webp" />
|
|
457
|
-
<source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
|
|
458
|
-
<img
|
|
459
|
-
[attr.alt]="data.description ?? undefined"
|
|
460
|
-
[width]="data.width ?? undefined"
|
|
461
|
-
[height]="data.height ?? undefined"
|
|
462
|
-
[priority]="data.priority ?? priority"
|
|
463
|
-
[ngClass]="imgClass"
|
|
464
|
-
ngSrc="{{ data.url }}"
|
|
465
|
-
/>
|
|
466
|
-
</picture>
|
|
467
|
-
`, 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 });
|
|
468
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulImageComponent, decorators: [{
|
|
469
|
-
type: Component,
|
|
470
|
-
args: [{
|
|
471
|
-
selector: 'et-contentful-image',
|
|
472
|
-
template: `
|
|
473
|
-
<picture *ngIf="data" [ngClass]="pictureClass">
|
|
474
|
-
<source srcset="{{ data.url }}?fm=avif" type="image/avif" />
|
|
475
|
-
<source srcset="{{ data.url }}?fm=webp" type="image/webp" />
|
|
476
|
-
<source srcset="{{ data.url }}?fm=jpg" type="image/jpeg" />
|
|
477
|
-
<img
|
|
478
|
-
[attr.alt]="data.description ?? undefined"
|
|
479
|
-
[width]="data.width ?? undefined"
|
|
480
|
-
[height]="data.height ?? undefined"
|
|
481
|
-
[priority]="data.priority ?? priority"
|
|
482
|
-
[ngClass]="imgClass"
|
|
483
|
-
ngSrc="{{ data.url }}"
|
|
484
|
-
/>
|
|
485
|
-
</picture>
|
|
486
|
-
`,
|
|
487
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
488
|
-
encapsulation: ViewEncapsulation.None,
|
|
489
|
-
standalone: true,
|
|
490
|
-
imports: [NgIf, NgClass, NgOptimizedImage],
|
|
491
|
-
}]
|
|
492
|
-
}], propDecorators: { data: [{
|
|
493
|
-
type: Input
|
|
494
|
-
}], imgClass: [{
|
|
495
|
-
type: Input
|
|
496
|
-
}], pictureClass: [{
|
|
497
|
-
type: Input
|
|
498
|
-
}], priority: [{
|
|
499
|
-
type: Input
|
|
500
|
-
}] } });
|
|
501
|
-
|
|
502
657
|
class ContentfulVideoComponent {
|
|
503
658
|
constructor() {
|
|
504
659
|
this._richTextData = inject(RICH_TEXT_RENDERER_COMPONENT_DATA, { optional: true });
|
|
@@ -525,13 +680,13 @@ class ContentfulVideoComponent {
|
|
|
525
680
|
}
|
|
526
681
|
}
|
|
527
682
|
}
|
|
528
|
-
ContentfulVideoComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.
|
|
529
|
-
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: `
|
|
530
685
|
<video *ngIf="data" [ngClass]="videoClass" controls>
|
|
531
686
|
<source src="{{ data.url }}" type="{{ data.contentType }}" />
|
|
532
687
|
</video>
|
|
533
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 });
|
|
534
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.
|
|
689
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.4", ngImport: i0, type: ContentfulVideoComponent, decorators: [{
|
|
535
690
|
type: Component,
|
|
536
691
|
args: [{
|
|
537
692
|
selector: 'et-contentful-video',
|
|
@@ -551,50 +706,48 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImpor
|
|
|
551
706
|
type: Input
|
|
552
707
|
}] } });
|
|
553
708
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
ContentfulRichTextRendererComponent], exports: [ContentfulAudioComponent,
|
|
562
|
-
ContentfulFileComponent,
|
|
563
|
-
ContentfulImageComponent,
|
|
564
|
-
ContentfulVideoComponent,
|
|
565
|
-
ContentfulRichTextRendererComponent] });
|
|
566
|
-
ContentfulModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulModule, imports: [ContentfulAudioComponent,
|
|
567
|
-
ContentfulFileComponent,
|
|
568
|
-
ContentfulImageComponent,
|
|
569
|
-
ContentfulVideoComponent,
|
|
570
|
-
ContentfulRichTextRendererComponent] });
|
|
571
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.2", ngImport: i0, type: ContentfulModule, decorators: [{
|
|
572
|
-
type: NgModule,
|
|
573
|
-
args: [{
|
|
574
|
-
imports: [
|
|
575
|
-
ContentfulAudioComponent,
|
|
576
|
-
ContentfulFileComponent,
|
|
577
|
-
ContentfulImageComponent,
|
|
578
|
-
ContentfulVideoComponent,
|
|
579
|
-
ContentfulRichTextRendererComponent,
|
|
580
|
-
],
|
|
581
|
-
exports: [
|
|
582
|
-
ContentfulAudioComponent,
|
|
583
|
-
ContentfulFileComponent,
|
|
584
|
-
ContentfulImageComponent,
|
|
585
|
-
ContentfulVideoComponent,
|
|
586
|
-
ContentfulRichTextRendererComponent,
|
|
587
|
-
],
|
|
588
|
-
}]
|
|
589
|
-
}] });
|
|
709
|
+
const ContentfulImports = [
|
|
710
|
+
ContentfulAudioComponent,
|
|
711
|
+
ContentfulFileComponent,
|
|
712
|
+
ContentfulImageComponent,
|
|
713
|
+
ContentfulVideoComponent,
|
|
714
|
+
ContentfulRichTextRendererComponent,
|
|
715
|
+
];
|
|
590
716
|
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
717
|
+
const GQL_FRAGMENT_CONTENTFUL_ASSET = gql `
|
|
718
|
+
fragment AssetData on Asset {
|
|
719
|
+
sys {
|
|
720
|
+
id
|
|
721
|
+
}
|
|
722
|
+
url
|
|
723
|
+
title
|
|
724
|
+
width
|
|
725
|
+
height
|
|
726
|
+
description
|
|
727
|
+
contentType
|
|
728
|
+
size
|
|
729
|
+
}
|
|
730
|
+
`;
|
|
731
|
+
const GQL_FRAGMENT_CONTENTFUL_IMAGE = gql `
|
|
732
|
+
fragment ImageData on Image {
|
|
733
|
+
sys {
|
|
734
|
+
id
|
|
735
|
+
}
|
|
736
|
+
asset {
|
|
737
|
+
...AssetData
|
|
738
|
+
}
|
|
739
|
+
alt
|
|
740
|
+
caption
|
|
741
|
+
resizeBehavior
|
|
742
|
+
focusArea
|
|
743
|
+
quality
|
|
744
|
+
__typename
|
|
745
|
+
}
|
|
746
|
+
`;
|
|
594
747
|
|
|
595
748
|
/**
|
|
596
749
|
* Generated bundle index. Do not edit.
|
|
597
750
|
*/
|
|
598
751
|
|
|
599
|
-
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 };
|
|
600
753
|
//# sourceMappingURL=ethlete-contentful.mjs.map
|