@ndla/article-converter 2.5.18 → 3.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.
@@ -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
@@ -24,7 +24,6 @@ export var fileEmbedPlugin = function fileEmbedPlugin(element) {
24
24
  });
25
25
  } else {
26
26
  return _jsx(FileV2, {
27
- id: "file-".concat(data.seq),
28
27
  url: url,
29
28
  title: title,
30
29
  fileExists: data.status === 'success' ? !!data.data.exists : false,
@@ -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
@@ -30,7 +30,6 @@ var fileEmbedPlugin = function fileEmbedPlugin(element) {
30
30
  });
31
31
  } else {
32
32
  return (0, _jsxRuntime.jsx)(_ui.FileV2, {
33
- id: "file-".concat(data.seq),
34
33
  url: url,
35
34
  title: title,
36
35
  fileExists: data.status === 'success' ? !!data.data.exists : false,
@@ -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": "2.5.18",
3
+ "version": "3.0.1",
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,11 @@
27
27
  "src"
28
28
  ],
29
29
  "devDependencies": {
30
- "@ndla/types-embed": "^2.0.7"
30
+ "@ndla/types-embed": "^3.0.0"
31
31
  },
32
32
  "dependencies": {
33
- "@ndla/code": "^2.2.25",
34
- "@ndla/ui": "^44.0.18",
33
+ "@ndla/code": "^2.2.26",
34
+ "@ndla/ui": "^44.0.20",
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": "fba17b5a3a2e5597989893efe533008a3e162941"
47
+ "gitHead": "ea6f289e6d960c63f02ba9a75d631b30ba31db97"
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 }
@@ -20,7 +20,6 @@ export const fileEmbedPlugin: PluginType = (element) => {
20
20
  } else {
21
21
  return (
22
22
  <FileV2
23
- id={`file-${data.seq}`}
24
23
  url={url}
25
24
  title={title}
26
25
  fileExists={data.status === 'success' ? !!data.data.exists : false}
@@ -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
  };