@ndla/article-converter 1.0.25 → 1.0.26
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 +36 -0
- package/es/plugins/embed/index.js +2 -0
- package/lib/plugins/embed/blogPostEmbedPlugin.d.ts +10 -0
- package/lib/plugins/embed/blogPostEmbedPlugin.js +44 -0
- package/lib/plugins/embed/index.js +2 -0
- package/package.json +5 -5
- package/src/plugins/embed/blogPostEmbedPlugin.tsx +32 -0
- package/src/plugins/embed/index.ts +2 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { attributesToProps } from 'html-react-parser';
|
|
10
|
+
import { BlogPostV2 } from '@ndla/ui';
|
|
11
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
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) {
|
|
14
|
+
var _data$data$metaImage$, _data$data$metaImage;
|
|
15
|
+
var props = attributesToProps(element.attribs);
|
|
16
|
+
var data = JSON.parse(props['data-json']);
|
|
17
|
+
var _data$embedData = data.embedData,
|
|
18
|
+
title = _data$embedData.title,
|
|
19
|
+
author = _data$embedData.author,
|
|
20
|
+
url = _data$embedData.url,
|
|
21
|
+
size = _data$embedData.size,
|
|
22
|
+
language = _data$embedData.language;
|
|
23
|
+
return _jsx(BlogPostV2, {
|
|
24
|
+
title: {
|
|
25
|
+
title: title,
|
|
26
|
+
language: language
|
|
27
|
+
},
|
|
28
|
+
author: author,
|
|
29
|
+
url: url,
|
|
30
|
+
size: size,
|
|
31
|
+
metaImage: {
|
|
32
|
+
alt: '',
|
|
33
|
+
url: data.status === 'success' ? (_data$data$metaImage$ = (_data$data$metaImage = data.data.metaImage) === null || _data$data$metaImage === void 0 ? void 0 : _data$data$metaImage.imageUrl) !== null && _data$data$metaImage$ !== void 0 ? _data$data$metaImage$ : errorSvgSrc : errorSvgSrc
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
@@ -19,6 +19,7 @@ import { conceptEmbedPlugin } from './conceptEmbedPlugin';
|
|
|
19
19
|
import { conceptListEmbedPlugin } from './conceptListEmbedPlugin';
|
|
20
20
|
import { fileEmbedPlugin } from './fileEmbedPlugin';
|
|
21
21
|
import { codeEmbedPlugin } from './codeEmbedPlugin';
|
|
22
|
+
import { blogPostEmbedPlugin } from './blogPostEmbedPlugin';
|
|
22
23
|
export var embedPlugins = {
|
|
23
24
|
image: imageEmbedPlugin,
|
|
24
25
|
audio: audioEmbedPlugin,
|
|
@@ -32,5 +33,6 @@ export var embedPlugins = {
|
|
|
32
33
|
'content-link': contentLinkEmbedPlugin,
|
|
33
34
|
concept: conceptEmbedPlugin,
|
|
34
35
|
'concept-list': conceptListEmbedPlugin,
|
|
36
|
+
'blog-post': blogPostEmbedPlugin,
|
|
35
37
|
file: fileEmbedPlugin
|
|
36
38
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import { PluginType } from '../types';
|
|
9
|
+
export declare 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";
|
|
10
|
+
export declare const blogPostEmbedPlugin: PluginType;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.errorSvgSrc = exports.blogPostEmbedPlugin = void 0;
|
|
7
|
+
var _htmlReactParser = require("html-react-parser");
|
|
8
|
+
var _ui = require("@ndla/ui");
|
|
9
|
+
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) 2023-present, NDLA.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
|
|
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
|
+
exports.errorSvgSrc = errorSvgSrc;
|
|
20
|
+
var blogPostEmbedPlugin = function blogPostEmbedPlugin(element) {
|
|
21
|
+
var _data$data$metaImage$, _data$data$metaImage;
|
|
22
|
+
var props = (0, _htmlReactParser.attributesToProps)(element.attribs);
|
|
23
|
+
var data = JSON.parse(props['data-json']);
|
|
24
|
+
var _data$embedData = data.embedData,
|
|
25
|
+
title = _data$embedData.title,
|
|
26
|
+
author = _data$embedData.author,
|
|
27
|
+
url = _data$embedData.url,
|
|
28
|
+
size = _data$embedData.size,
|
|
29
|
+
language = _data$embedData.language;
|
|
30
|
+
return (0, _jsxRuntime.jsx)(_ui.BlogPostV2, {
|
|
31
|
+
title: {
|
|
32
|
+
title: title,
|
|
33
|
+
language: language
|
|
34
|
+
},
|
|
35
|
+
author: author,
|
|
36
|
+
url: url,
|
|
37
|
+
size: size,
|
|
38
|
+
metaImage: {
|
|
39
|
+
alt: '',
|
|
40
|
+
url: data.status === 'success' ? (_data$data$metaImage$ = (_data$data$metaImage = data.data.metaImage) === null || _data$data$metaImage === void 0 ? void 0 : _data$data$metaImage.imageUrl) !== null && _data$data$metaImage$ !== void 0 ? _data$data$metaImage$ : errorSvgSrc : errorSvgSrc
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
exports.blogPostEmbedPlugin = blogPostEmbedPlugin;
|
|
@@ -17,6 +17,7 @@ var _conceptEmbedPlugin = require("./conceptEmbedPlugin");
|
|
|
17
17
|
var _conceptListEmbedPlugin = require("./conceptListEmbedPlugin");
|
|
18
18
|
var _fileEmbedPlugin = require("./fileEmbedPlugin");
|
|
19
19
|
var _codeEmbedPlugin = require("./codeEmbedPlugin");
|
|
20
|
+
var _blogPostEmbedPlugin = require("./blogPostEmbedPlugin");
|
|
20
21
|
/**
|
|
21
22
|
* Copyright (c) 2023-present, NDLA.
|
|
22
23
|
*
|
|
@@ -38,6 +39,7 @@ var embedPlugins = {
|
|
|
38
39
|
'content-link': _contentLinkEmbedPlugin.contentLinkEmbedPlugin,
|
|
39
40
|
concept: _conceptEmbedPlugin.conceptEmbedPlugin,
|
|
40
41
|
'concept-list': _conceptListEmbedPlugin.conceptListEmbedPlugin,
|
|
42
|
+
'blog-post': _blogPostEmbedPlugin.blogPostEmbedPlugin,
|
|
41
43
|
file: _fileEmbedPlugin.fileEmbedPlugin
|
|
42
44
|
};
|
|
43
45
|
exports.embedPlugins = embedPlugins;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ndla/article-converter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
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": "^1.0.
|
|
30
|
+
"@ndla/types-embed": "^1.0.7"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@ndla/code": "^2.1.
|
|
34
|
-
"@ndla/ui": "^35.0.
|
|
33
|
+
"@ndla/code": "^2.1.33",
|
|
34
|
+
"@ndla/ui": "^35.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": "
|
|
47
|
+
"gitHead": "496319a9a156a2ec659bb9cf119d35654281417b"
|
|
48
48
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2023-present, NDLA.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the GPLv3 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { attributesToProps } from 'html-react-parser';
|
|
10
|
+
import { BlogPostMeta } from '@ndla/types-embed';
|
|
11
|
+
import { BlogPostV2 } from '@ndla/ui';
|
|
12
|
+
import { PluginType } from '../types';
|
|
13
|
+
|
|
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
|
+
|
|
16
|
+
export const blogPostEmbedPlugin: PluginType = (element) => {
|
|
17
|
+
const props = attributesToProps(element.attribs);
|
|
18
|
+
const data = JSON.parse(props['data-json']) as BlogPostMeta;
|
|
19
|
+
const { title, author, url, size, language } = data.embedData;
|
|
20
|
+
return (
|
|
21
|
+
<BlogPostV2
|
|
22
|
+
title={{ title, language }}
|
|
23
|
+
author={author}
|
|
24
|
+
url={url}
|
|
25
|
+
size={size}
|
|
26
|
+
metaImage={{
|
|
27
|
+
alt: '',
|
|
28
|
+
url: data.status === 'success' ? data.data.metaImage?.imageUrl ?? errorSvgSrc : errorSvgSrc,
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -20,6 +20,7 @@ import { conceptEmbedPlugin } from './conceptEmbedPlugin';
|
|
|
20
20
|
import { conceptListEmbedPlugin } from './conceptListEmbedPlugin';
|
|
21
21
|
import { fileEmbedPlugin } from './fileEmbedPlugin';
|
|
22
22
|
import { codeEmbedPlugin } from './codeEmbedPlugin';
|
|
23
|
+
import { blogPostEmbedPlugin } from './blogPostEmbedPlugin';
|
|
23
24
|
|
|
24
25
|
export const embedPlugins: Record<string, PluginType> = {
|
|
25
26
|
image: imageEmbedPlugin,
|
|
@@ -34,5 +35,6 @@ export const embedPlugins: Record<string, PluginType> = {
|
|
|
34
35
|
'content-link': contentLinkEmbedPlugin,
|
|
35
36
|
concept: conceptEmbedPlugin,
|
|
36
37
|
'concept-list': conceptListEmbedPlugin,
|
|
38
|
+
'blog-post': blogPostEmbedPlugin,
|
|
37
39
|
file: fileEmbedPlugin,
|
|
38
40
|
};
|