@ndla/article-converter 6.0.4 → 6.0.6
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/es/plugins/embed/contactBlockEmbedPlugin.js +6 -2
- package/es/plugins/embed/imageEmbedPlugin.js +2 -1
- package/lib/plugins/embed/contactBlockEmbedPlugin.js +6 -2
- package/lib/plugins/embed/imageEmbedPlugin.js +2 -1
- package/lib/plugins/types.d.ts +2 -1
- package/package.json +6 -5
- package/src/plugins/embed/contactBlockEmbedPlugin.tsx +3 -1
- package/src/plugins/embed/imageEmbedPlugin.tsx +1 -0
- package/src/plugins/types.ts +2 -1
|
@@ -10,6 +10,7 @@ import { ContactBlock } from '@ndla/ui';
|
|
|
10
10
|
import { attributesToProps } from 'html-react-parser';
|
|
11
11
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
12
12
|
export var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element, _, opts) {
|
|
13
|
+
var _opts$canonicalUrls;
|
|
13
14
|
var props = attributesToProps(element.attribs);
|
|
14
15
|
var embedData = JSON.parse(props['data-json']);
|
|
15
16
|
var _embedData$embedData = embedData.embedData,
|
|
@@ -18,15 +19,18 @@ export var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element, _
|
|
|
18
19
|
description = _embedData$embedData.description,
|
|
19
20
|
blob = _embedData$embedData.blob,
|
|
20
21
|
blobColor = _embedData$embedData.blobColor,
|
|
21
|
-
jobTitle = _embedData$embedData.jobTitle
|
|
22
|
+
jobTitle = _embedData$embedData.jobTitle,
|
|
23
|
+
alt = _embedData$embedData.alt;
|
|
22
24
|
return _jsx(ContactBlock, {
|
|
23
25
|
image: embedData.status === 'success' ? embedData.data.image : undefined,
|
|
26
|
+
embedAlt: alt,
|
|
24
27
|
description: description,
|
|
25
28
|
email: email,
|
|
26
29
|
blobColor: blobColor,
|
|
27
30
|
jobTitle: jobTitle,
|
|
28
31
|
name: name,
|
|
29
32
|
blob: blob,
|
|
30
|
-
lang: opts.articleLanguage
|
|
33
|
+
lang: opts.articleLanguage,
|
|
34
|
+
imageCanonicalUrl: (_opts$canonicalUrls = opts.canonicalUrls) === null || _opts$canonicalUrls === void 0 ? void 0 : _opts$canonicalUrls.image
|
|
31
35
|
});
|
|
32
36
|
};
|
|
@@ -10,7 +10,7 @@ import { ImageEmbed } from '@ndla/ui';
|
|
|
10
10
|
import { attributesToProps } from 'html-react-parser';
|
|
11
11
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
12
12
|
export var imageEmbedPlugin = function imageEmbedPlugin(element, _, opts) {
|
|
13
|
-
var _element$parentNode, _element$parentNode$p, _element$parentNode$p2, _opts$components;
|
|
13
|
+
var _element$parentNode, _element$parentNode$p, _element$parentNode$p2, _opts$components, _opts$canonicalUrls;
|
|
14
14
|
var props = attributesToProps(element.attribs);
|
|
15
15
|
var data = JSON.parse(props['data-json']);
|
|
16
16
|
var inGrid = ((_element$parentNode = element.parentNode) === null || _element$parentNode === void 0 ? void 0 : (_element$parentNode$p = _element$parentNode.parentNode) === null || _element$parentNode$p === void 0 ? void 0 : (_element$parentNode$p2 = _element$parentNode$p.attribs) === null || _element$parentNode$p2 === void 0 ? void 0 : _element$parentNode$p2['data-type']) === 'grid';
|
|
@@ -20,6 +20,7 @@ export var imageEmbedPlugin = function imageEmbedPlugin(element, _, opts) {
|
|
|
20
20
|
path: opts.path,
|
|
21
21
|
previewAlt: opts.previewAlt,
|
|
22
22
|
heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
|
|
23
|
+
canonicalUrl: (_opts$canonicalUrls = opts.canonicalUrls) === null || _opts$canonicalUrls === void 0 ? void 0 : _opts$canonicalUrls.image,
|
|
23
24
|
lang: opts.articleLanguage,
|
|
24
25
|
renderContext: opts.renderContext
|
|
25
26
|
});
|
|
@@ -16,6 +16,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element, _, opts) {
|
|
19
|
+
var _opts$canonicalUrls;
|
|
19
20
|
var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
21
|
var embedData = JSON.parse(props['data-json']);
|
|
21
22
|
var _embedData$embedData = embedData.embedData,
|
|
@@ -24,16 +25,19 @@ var contactBlockEmbedPlugin = function contactBlockEmbedPlugin(element, _, opts)
|
|
|
24
25
|
description = _embedData$embedData.description,
|
|
25
26
|
blob = _embedData$embedData.blob,
|
|
26
27
|
blobColor = _embedData$embedData.blobColor,
|
|
27
|
-
jobTitle = _embedData$embedData.jobTitle
|
|
28
|
+
jobTitle = _embedData$embedData.jobTitle,
|
|
29
|
+
alt = _embedData$embedData.alt;
|
|
28
30
|
return (0, _jsxRuntime.jsx)(_ui.ContactBlock, {
|
|
29
31
|
image: embedData.status === 'success' ? embedData.data.image : undefined,
|
|
32
|
+
embedAlt: alt,
|
|
30
33
|
description: description,
|
|
31
34
|
email: email,
|
|
32
35
|
blobColor: blobColor,
|
|
33
36
|
jobTitle: jobTitle,
|
|
34
37
|
name: name,
|
|
35
38
|
blob: blob,
|
|
36
|
-
lang: opts.articleLanguage
|
|
39
|
+
lang: opts.articleLanguage,
|
|
40
|
+
imageCanonicalUrl: (_opts$canonicalUrls = opts.canonicalUrls) === null || _opts$canonicalUrls === void 0 ? void 0 : _opts$canonicalUrls.image
|
|
37
41
|
});
|
|
38
42
|
};
|
|
39
43
|
exports.contactBlockEmbedPlugin = contactBlockEmbedPlugin;
|
|
@@ -16,7 +16,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
var imageEmbedPlugin = function imageEmbedPlugin(element, _, opts) {
|
|
19
|
-
var _element$parentNode, _element$parentNode$p, _element$parentNode$p2, _opts$components;
|
|
19
|
+
var _element$parentNode, _element$parentNode$p, _element$parentNode$p2, _opts$components, _opts$canonicalUrls;
|
|
20
20
|
var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
21
21
|
var data = JSON.parse(props['data-json']);
|
|
22
22
|
var inGrid = ((_element$parentNode = element.parentNode) === null || _element$parentNode === void 0 ? void 0 : (_element$parentNode$p = _element$parentNode.parentNode) === null || _element$parentNode$p === void 0 ? void 0 : (_element$parentNode$p2 = _element$parentNode$p.attribs) === null || _element$parentNode$p2 === void 0 ? void 0 : _element$parentNode$p2['data-type']) === 'grid';
|
|
@@ -26,6 +26,7 @@ var imageEmbedPlugin = function imageEmbedPlugin(element, _, opts) {
|
|
|
26
26
|
path: opts.path,
|
|
27
27
|
previewAlt: opts.previewAlt,
|
|
28
28
|
heartButton: (_opts$components = opts.components) === null || _opts$components === void 0 ? void 0 : _opts$components.heartButton,
|
|
29
|
+
canonicalUrl: (_opts$canonicalUrls = opts.canonicalUrls) === null || _opts$canonicalUrls === void 0 ? void 0 : _opts$canonicalUrls.image,
|
|
29
30
|
lang: opts.articleLanguage,
|
|
30
31
|
renderContext: opts.renderContext
|
|
31
32
|
});
|
package/lib/plugins/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
/// <reference types="react" />
|
|
9
|
-
import { HeartButtonType, RenderContext } from '@ndla/ui';
|
|
9
|
+
import { HeartButtonType, RenderContext, CanonicalUrlFuncs } from '@ndla/ui';
|
|
10
10
|
import { Element, HTMLReactParserOptions } from 'html-react-parser';
|
|
11
11
|
export interface DynamicComponents {
|
|
12
12
|
heartButton?: HeartButtonType;
|
|
@@ -19,6 +19,7 @@ export interface TransformOptions {
|
|
|
19
19
|
frontendDomain?: string;
|
|
20
20
|
components?: DynamicComponents;
|
|
21
21
|
articleLanguage?: string;
|
|
22
|
+
canonicalUrls?: CanonicalUrlFuncs;
|
|
22
23
|
renderContext?: RenderContext;
|
|
23
24
|
}
|
|
24
25
|
export type PluginType = (element: Element, options: HTMLReactParserOptions, metaData: TransformOptions) => JSX.Element | undefined | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/article-converter",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.6",
|
|
4
4
|
"description": "Transforms NDLA articles into extended html versions",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
"src"
|
|
28
28
|
],
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@ndla/types-
|
|
30
|
+
"@ndla/types-backend": "^0.2.21",
|
|
31
|
+
"@ndla/types-embed": "^4.0.7"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@ndla/code": "^5.0.
|
|
34
|
-
"@ndla/ui": "^49.0.
|
|
34
|
+
"@ndla/code": "^5.0.13",
|
|
35
|
+
"@ndla/ui": "^49.0.7",
|
|
35
36
|
"html-react-parser": "^4.2.2",
|
|
36
37
|
"lodash": "^4.17.20"
|
|
37
38
|
},
|
|
@@ -44,5 +45,5 @@
|
|
|
44
45
|
"publishConfig": {
|
|
45
46
|
"access": "public"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "5b6502dbc509b761ddea72112df15ee4fe633255"
|
|
48
49
|
}
|
|
@@ -14,10 +14,11 @@ import { PluginType } from '../types';
|
|
|
14
14
|
export const contactBlockEmbedPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const embedData = JSON.parse(props['data-json']) as ContactBlockMetaData;
|
|
17
|
-
const { name, email, description, blob, blobColor, jobTitle } = embedData.embedData;
|
|
17
|
+
const { name, email, description, blob, blobColor, jobTitle, alt } = embedData.embedData;
|
|
18
18
|
return (
|
|
19
19
|
<ContactBlock
|
|
20
20
|
image={embedData.status === 'success' ? embedData.data.image : undefined}
|
|
21
|
+
embedAlt={alt}
|
|
21
22
|
description={description}
|
|
22
23
|
email={email}
|
|
23
24
|
blobColor={blobColor}
|
|
@@ -25,6 +26,7 @@ export const contactBlockEmbedPlugin: PluginType = (element, _, opts) => {
|
|
|
25
26
|
name={name}
|
|
26
27
|
blob={blob}
|
|
27
28
|
lang={opts.articleLanguage}
|
|
29
|
+
imageCanonicalUrl={opts.canonicalUrls?.image}
|
|
28
30
|
/>
|
|
29
31
|
);
|
|
30
32
|
};
|
|
@@ -23,6 +23,7 @@ export const imageEmbedPlugin: PluginType = (element, _, opts) => {
|
|
|
23
23
|
path={opts.path}
|
|
24
24
|
previewAlt={opts.previewAlt}
|
|
25
25
|
heartButton={opts.components?.heartButton}
|
|
26
|
+
canonicalUrl={opts.canonicalUrls?.image}
|
|
26
27
|
lang={opts.articleLanguage}
|
|
27
28
|
renderContext={opts.renderContext}
|
|
28
29
|
/>
|
package/src/plugins/types.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { HeartButtonType, RenderContext } from '@ndla/ui';
|
|
9
|
+
import { HeartButtonType, RenderContext, CanonicalUrlFuncs } from '@ndla/ui';
|
|
10
10
|
import { Element, HTMLReactParserOptions } from 'html-react-parser';
|
|
11
11
|
|
|
12
12
|
export interface DynamicComponents {
|
|
@@ -21,6 +21,7 @@ export interface TransformOptions {
|
|
|
21
21
|
frontendDomain?: string;
|
|
22
22
|
components?: DynamicComponents;
|
|
23
23
|
articleLanguage?: string;
|
|
24
|
+
canonicalUrls?: CanonicalUrlFuncs;
|
|
24
25
|
renderContext?: RenderContext;
|
|
25
26
|
}
|
|
26
27
|
|