@ndla/article-converter 3.0.0 → 3.0.2
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/blogPostEmbedPlugin.js +2 -1
- package/es/plugins/embed/campaignBlockPlugin.js +2 -1
- package/es/plugins/embed/linkBlockEmbedPlugin.js +4 -2
- package/lib/plugins/embed/blogPostEmbedPlugin.js +2 -1
- package/lib/plugins/embed/campaignBlockPlugin.js +2 -1
- package/lib/plugins/embed/linkBlockEmbedPlugin.js +4 -2
- package/package.json +4 -4
- package/src/plugins/embed/blogPostEmbedPlugin.tsx +2 -1
- package/src/plugins/embed/campaignBlockPlugin.tsx +2 -1
- package/src/plugins/embed/linkBlockEmbedPlugin.tsx +2 -2
|
@@ -10,7 +10,7 @@ import { attributesToProps } from 'html-react-parser';
|
|
|
10
10
|
import { BlogPostV2 } from '@ndla/ui';
|
|
11
11
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
12
12
|
export var errorSvgSrc = "data:image/svg+xml;charset=UTF-8,%3Csvg fill='%238A8888' height='400' viewBox='0 0 24 12' width='100%25' xmlns='http://www.w3.org/2000/svg' style='background-color: %23EFF0F2'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath transform='scale(0.3) translate(28, 8.5)' d='M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z'/%3E%3C/svg%3E";
|
|
13
|
-
export var blogPostEmbedPlugin = function blogPostEmbedPlugin(element) {
|
|
13
|
+
export var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
|
|
14
14
|
var _data$data$metaImage$, _data$data$metaImage;
|
|
15
15
|
var props = attributesToProps(element.attribs);
|
|
16
16
|
var data = JSON.parse(props['data-json']);
|
|
@@ -28,6 +28,7 @@ export var blogPostEmbedPlugin = function blogPostEmbedPlugin(element) {
|
|
|
28
28
|
author: author,
|
|
29
29
|
url: url,
|
|
30
30
|
size: size,
|
|
31
|
+
path: opts.path,
|
|
31
32
|
metaImage: {
|
|
32
33
|
alt: '',
|
|
33
34
|
url: data.status === 'success' ? (_data$data$metaImage$ = (_data$data$metaImage = data.data.metaImage) === null || _data$data$metaImage === void 0 ? void 0 : _data$data$metaImage.image.imageUrl) !== null && _data$data$metaImage$ !== void 0 ? _data$data$metaImage$ : errorSvgSrc : errorSvgSrc
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { attributesToProps } from 'html-react-parser';
|
|
10
10
|
import { CampaignBlock } from '@ndla/ui';
|
|
11
11
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
12
|
-
export var campaignBlockPlugin = function campaignBlockPlugin(element) {
|
|
12
|
+
export var campaignBlockPlugin = function campaignBlockPlugin(element, _, opts) {
|
|
13
13
|
var props = attributesToProps(element.attribs);
|
|
14
14
|
var data = JSON.parse(props['data-json']);
|
|
15
15
|
var embed = data.embedData;
|
|
@@ -26,6 +26,7 @@ export var campaignBlockPlugin = function campaignBlockPlugin(element) {
|
|
|
26
26
|
url: embed.url,
|
|
27
27
|
text: embed.urlText
|
|
28
28
|
},
|
|
29
|
+
path: opts.path,
|
|
29
30
|
imageAfter: data.status === 'success' && data.data.imageAfter ? {
|
|
30
31
|
src: data.data.imageAfter.image.imageUrl,
|
|
31
32
|
alt: data.data.imageAfter.alttext.alttext
|
|
@@ -15,8 +15,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
15
15
|
import { LinkBlock } from '@ndla/ui';
|
|
16
16
|
import { attributesToProps } from 'html-react-parser';
|
|
17
17
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
18
|
-
export var linkBlockPlugin = function linkBlockPlugin(element) {
|
|
18
|
+
export var linkBlockPlugin = function linkBlockPlugin(element, _, opts) {
|
|
19
19
|
var props = attributesToProps(element.attribs);
|
|
20
20
|
var data = JSON.parse(props['data-json']);
|
|
21
|
-
return _jsx(LinkBlock, _objectSpread({}, data.embedData)
|
|
21
|
+
return _jsx(LinkBlock, _objectSpread(_objectSpread({}, data.embedData), {}, {
|
|
22
|
+
path: opts.path
|
|
23
|
+
}));
|
|
22
24
|
};
|
|
@@ -17,7 +17,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
17
17
|
|
|
18
18
|
var errorSvgSrc = "data:image/svg+xml;charset=UTF-8,%3Csvg fill='%238A8888' height='400' viewBox='0 0 24 12' width='100%25' xmlns='http://www.w3.org/2000/svg' style='background-color: %23EFF0F2'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath transform='scale(0.3) translate(28, 8.5)' d='M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z'/%3E%3C/svg%3E";
|
|
19
19
|
exports.errorSvgSrc = errorSvgSrc;
|
|
20
|
-
var blogPostEmbedPlugin = function blogPostEmbedPlugin(element) {
|
|
20
|
+
var blogPostEmbedPlugin = function blogPostEmbedPlugin(element, _, opts) {
|
|
21
21
|
var _data$data$metaImage$, _data$data$metaImage;
|
|
22
22
|
var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
23
23
|
var data = JSON.parse(props['data-json']);
|
|
@@ -35,6 +35,7 @@ var blogPostEmbedPlugin = function blogPostEmbedPlugin(element) {
|
|
|
35
35
|
author: author,
|
|
36
36
|
url: url,
|
|
37
37
|
size: size,
|
|
38
|
+
path: opts.path,
|
|
38
39
|
metaImage: {
|
|
39
40
|
alt: '',
|
|
40
41
|
url: data.status === 'success' ? (_data$data$metaImage$ = (_data$data$metaImage = data.data.metaImage) === null || _data$data$metaImage === void 0 ? void 0 : _data$data$metaImage.image.imageUrl) !== null && _data$data$metaImage$ !== void 0 ? _data$data$metaImage$ : errorSvgSrc : errorSvgSrc
|
|
@@ -15,7 +15,7 @@ var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
var campaignBlockPlugin = function campaignBlockPlugin(element) {
|
|
18
|
+
var campaignBlockPlugin = function campaignBlockPlugin(element, _, opts) {
|
|
19
19
|
var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
20
20
|
var data = JSON.parse(props['data-json']);
|
|
21
21
|
var embed = data.embedData;
|
|
@@ -32,6 +32,7 @@ var campaignBlockPlugin = function campaignBlockPlugin(element) {
|
|
|
32
32
|
url: embed.url,
|
|
33
33
|
text: embed.urlText
|
|
34
34
|
},
|
|
35
|
+
path: opts.path,
|
|
35
36
|
imageAfter: data.status === 'success' && data.data.imageAfter ? {
|
|
36
37
|
src: data.data.imageAfter.image.imageUrl,
|
|
37
38
|
alt: data.data.imageAfter.alttext.alttext
|
|
@@ -19,9 +19,11 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
|
|
|
19
19
|
* LICENSE file in the root directory of this source tree.
|
|
20
20
|
*
|
|
21
21
|
*/
|
|
22
|
-
var linkBlockPlugin = function linkBlockPlugin(element) {
|
|
22
|
+
var linkBlockPlugin = function linkBlockPlugin(element, _, opts) {
|
|
23
23
|
var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
24
24
|
var data = JSON.parse(props['data-json']);
|
|
25
|
-
return (0, _jsxRuntime.jsx)(_ui.LinkBlock, _objectSpread({}, data.embedData)
|
|
25
|
+
return (0, _jsxRuntime.jsx)(_ui.LinkBlock, _objectSpread(_objectSpread({}, data.embedData), {}, {
|
|
26
|
+
path: opts.path
|
|
27
|
+
}));
|
|
26
28
|
};
|
|
27
29
|
exports.linkBlockPlugin = linkBlockPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/article-converter",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Transforms NDLA articles into extended html versions",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@ndla/types-embed": "^3.0.0"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ndla/code": "^2.2.
|
|
34
|
-
"@ndla/ui": "^44.0.
|
|
33
|
+
"@ndla/code": "^2.2.27",
|
|
34
|
+
"@ndla/ui": "^44.0.21",
|
|
35
35
|
"html-react-parser": "^3.0.8",
|
|
36
36
|
"lodash": "^4.17.20"
|
|
37
37
|
},
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "072f73eedfbdc11fd4a6412b756c3d3d9ca19d6a"
|
|
48
48
|
}
|
|
@@ -13,7 +13,7 @@ import { PluginType } from '../types';
|
|
|
13
13
|
|
|
14
14
|
export const errorSvgSrc = `data:image/svg+xml;charset=UTF-8,%3Csvg fill='%238A8888' height='400' viewBox='0 0 24 12' width='100%25' xmlns='http://www.w3.org/2000/svg' style='background-color: %23EFF0F2'%3E%3Cpath d='M0 0h24v24H0V0z' fill='none'/%3E%3Cpath transform='scale(0.3) translate(28, 8.5)' d='M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z'/%3E%3C/svg%3E`;
|
|
15
15
|
|
|
16
|
-
export const blogPostEmbedPlugin: PluginType = (element) => {
|
|
16
|
+
export const blogPostEmbedPlugin: PluginType = (element, _, opts) => {
|
|
17
17
|
const props = attributesToProps(element.attribs);
|
|
18
18
|
const data = JSON.parse(props['data-json']) as BlogPostMetaData;
|
|
19
19
|
const { title, author, url, size, language } = data.embedData;
|
|
@@ -23,6 +23,7 @@ export const blogPostEmbedPlugin: PluginType = (element) => {
|
|
|
23
23
|
author={author}
|
|
24
24
|
url={url}
|
|
25
25
|
size={size}
|
|
26
|
+
path={opts.path}
|
|
26
27
|
metaImage={{
|
|
27
28
|
alt: '',
|
|
28
29
|
url: data.status === 'success' ? data.data.metaImage?.image.imageUrl ?? errorSvgSrc : errorSvgSrc,
|
|
@@ -11,7 +11,7 @@ import { CampaignBlockMetaData } from '@ndla/types-embed';
|
|
|
11
11
|
import { CampaignBlock } from '@ndla/ui';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const campaignBlockPlugin: PluginType = (element) => {
|
|
14
|
+
export const campaignBlockPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as CampaignBlockMetaData;
|
|
17
17
|
const embed = data.embedData;
|
|
@@ -20,6 +20,7 @@ export const campaignBlockPlugin: PluginType = (element) => {
|
|
|
20
20
|
title={{ title: embed.title, language: embed.titleLanguage }}
|
|
21
21
|
description={{ text: embed.description, language: embed.descriptionLanguage }}
|
|
22
22
|
url={{ url: embed.url, text: embed.urlText }}
|
|
23
|
+
path={opts.path}
|
|
23
24
|
imageAfter={
|
|
24
25
|
data.status === 'success' && data.data.imageAfter
|
|
25
26
|
? { src: data.data.imageAfter.image.imageUrl, alt: data.data.imageAfter.alttext.alttext }
|
|
@@ -11,9 +11,9 @@ import { attributesToProps } from 'html-react-parser';
|
|
|
11
11
|
import { LinkBlockMetaData } from '@ndla/types-embed';
|
|
12
12
|
import { PluginType } from '../types';
|
|
13
13
|
|
|
14
|
-
export const linkBlockPlugin: PluginType = (element) => {
|
|
14
|
+
export const linkBlockPlugin: PluginType = (element, _, opts) => {
|
|
15
15
|
const props = attributesToProps(element.attribs);
|
|
16
16
|
const data = JSON.parse(props['data-json']) as LinkBlockMetaData;
|
|
17
17
|
|
|
18
|
-
return <LinkBlock {...data.embedData} />;
|
|
18
|
+
return <LinkBlock {...data.embedData} path={opts.path} />;
|
|
19
19
|
};
|