@bbc/morty-docs 3.0.3 → 4.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.
@@ -1,84 +0,0 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
- const React = require('react');
3
- const ReactDOMServer = require('react-dom/server');
4
- const Header = require('./Components/Header');
5
- const Title = require('./Components/Title');
6
- const Footer = require('./Components/Footer');
7
- const IndexListItem = require('./Components/IndexListItem');
8
- const Reset = require('./Components/Reset');
9
- const Styles = {
10
- headingContainer: {
11
- padding: '40px 15px',
12
- textAlign: 'center'
13
- },
14
- subtitle: {
15
- fontSize: '1.9em',
16
- marginTop: '0.5em'
17
- },
18
- logo: {
19
- maxWidth: '100%'
20
- },
21
- mortyLogo: {
22
- maxWidth: '45%'
23
- },
24
- wrapper: {
25
- minHeight: '75vh',
26
- paddingBottom: '20px'
27
- },
28
- html: {
29
- minHeight: '100vh',
30
- fontSize: '16px'
31
- },
32
- body: {
33
- minHeight: '100vh',
34
- fontFamily: '"Helvetica Neue",Helvetica,Arial,sans-serif',
35
- color: '#333',
36
- backgroundColor: '#fff'
37
- },
38
- listContainer: {
39
- marginTop: '10px',
40
- maxWidth: '600px',
41
- margin: 'auto'
42
- }
43
- };
44
- const IndexPage = ({
45
- listItems,
46
- options,
47
- relPath
48
- }) => {
49
- return React.createElement("html", {
50
- lang: "en",
51
- style: Styles.html
52
- }, React.createElement("head", null, React.createElement("meta", {
53
- charSet: "utf-8"
54
- }), React.createElement("meta", {
55
- httpEquiv: "X-UA-Compatible",
56
- content: "IE=edge"
57
- }), React.createElement("meta", {
58
- name: "viewport",
59
- content: "width=device-width, initial-scale=1"
60
- }), React.createElement("title", null, `Morty Docs`), React.createElement(Reset, null)), React.createElement("body", {
61
- style: Styles.body
62
- }, React.createElement("div", {
63
- style: Styles.wrapper
64
- }, React.createElement(Header, {
65
- relPath: relPath,
66
- basePath: options.basePath
67
- }), React.createElement("div", {
68
- style: {
69
- marginTop: '10px'
70
- }
71
- }, React.createElement(Title, {
72
- contentTitle: options.contentTitle
73
- }), React.createElement("div", {
74
- style: Styles.listContainer
75
- }, React.createElement("ul", null, (() => listItems.map((item, index) => React.createElement(IndexListItem, _extends({
76
- key: index
77
- }, item))))())))), React.createElement(Footer, null)));
78
- };
79
- const renderIndexPage = (listItems, options, htmlFilePaths) => ReactDOMServer.renderToString(React.createElement(IndexPage, {
80
- listItems: listItems,
81
- options: options,
82
- relPath: htmlFilePaths
83
- }));
84
- module.exports = renderIndexPage;
@@ -1,211 +0,0 @@
1
- const React = require('react');
2
- const ReactDOMServer = require('react-dom/server');
3
- const Header = require('./Components/Header');
4
- const Footer = require('./Components/Footer');
5
- const Reset = require('./Components/Reset');
6
- const Styles = {
7
- wrapper: {
8
- minHeight: '75vh',
9
- paddingBottom: '20px'
10
- },
11
- html: {
12
- minHeight: '100vh',
13
- fontSize: '16px'
14
- },
15
- body: {
16
- minHeight: '100vh',
17
- fontFamily: '"Helvetica Neue",Helvetica,Arial,sans-serif',
18
- color: '#333',
19
- backgroundColor: '#fff'
20
- }
21
- };
22
- const contentStyles = `
23
- .content {
24
- padding: 20px 96px;
25
- line-height: 1.42857143;
26
- max-width: 960px;
27
- margin: 0 auto;
28
- }
29
-
30
- .content a {
31
- color: #337ab7;
32
- text-decoration: none;
33
- }
34
-
35
- .content h1 {
36
- font-size: 2.2rem;
37
- font-weight: 500;
38
- margin-top: 20px;
39
- margin-bottom: 10px;
40
- }
41
-
42
- .content h2 {
43
- font-size: 1.8rem;
44
- font-weight: 500;
45
- margin-top: 20px;
46
- margin-bottom: 10px;
47
- }
48
-
49
- .content h3 {
50
- font-size: 1.5rem;
51
- font-weight: 500;
52
- margin-top: 20px;
53
- margin-bottom: 10px;
54
- }
55
-
56
- .content ul {
57
- display: block;
58
- list-style-type: disc;
59
- margin-block-start: 1em;
60
- margin-block-end: 1em;
61
- padding-inline-start: 40px;
62
- margin-bottom: 10px;
63
- }
64
-
65
- .content ol {
66
- list-style-type: decimal;
67
- display: block;
68
- margin-block-start: 1em;
69
- margin-block-end: 1em;
70
- padding-inline-start: 40px;
71
- }
72
-
73
- .content p {
74
- margin-bottom: 10px;
75
- }
76
-
77
- .content img {
78
- display: block;
79
- max-width: 100%;
80
- height: auto;
81
- vertical-align: middle;
82
- }
83
-
84
- .content strong {
85
- font-weight: 700;
86
- }
87
-
88
- .content em {
89
- font-style: italic;
90
- }
91
-
92
- .content blockquote {
93
- padding: 10px 20px;
94
- margin: 0 0 20px;
95
- font-size: 17.5px;
96
- border-left: 5px solid #eee;
97
- }
98
-
99
- .content blockquote p:last-child {
100
- margin-bottom: 0;
101
- }
102
-
103
- .content hr {
104
- margin-top: 20px;
105
- margin-bottom: 20px;
106
- border: 0;
107
- border-top: 1px solid #949494;
108
- }
109
-
110
- .content pre {
111
- display: block;
112
- padding: 9.5px;
113
- margin: 0 0 10px;
114
- font-size: 13px;
115
- line-height: 1.42857143;
116
- color: #333;
117
- word-break: break-all;
118
- word-wrap: break-word;
119
- background-color: #f5f5f5;
120
- border: 1px solid #ccc;
121
- border-radius: 4px;
122
- }
123
-
124
- .content code {
125
- font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
126
- }
127
-
128
- .content pre code {
129
- padding: 0;
130
- font-size: inherit;
131
- color: inherit;
132
- white-space: pre-wrap;
133
- background-color: transparent;
134
- border-radius: 0;
135
- }
136
-
137
- .content :not(pre) code {
138
- padding: 2px 4px;
139
- font-size: 90%;
140
- color: #c7254e;
141
- background-color: #f9f2f4;
142
- border-radius: 4px;
143
- }
144
-
145
- .content table {
146
- background-color: transparent;
147
- border-spacing: 0;
148
- border-collapse: collapse;
149
- width: 100%;
150
- max-width: 100%;
151
- margin-bottom: 20px;
152
- }
153
-
154
- .content th {
155
- text-align: left;
156
- vertical-align: bottom;
157
- border-bottom: 2px solid #ddd;
158
- font-weight: bold;
159
- font-size: 1.2rem;
160
- padding: 8px;
161
- line-height: 1.42857143;
162
- }
163
-
164
- .content td {
165
- padding: 8px;
166
- line-height: 1.42857143;
167
- vertical-align: top;
168
- border-top: 1px solid #ddd;
169
- }
170
-
171
- `;
172
- const MortyPage = ({
173
- relPath,
174
- body,
175
- options
176
- }) => {
177
- return React.createElement("html", {
178
- lang: "en",
179
- style: Styles.html
180
- }, React.createElement("head", null, React.createElement("meta", {
181
- charSet: "utf-8"
182
- }), React.createElement("meta", {
183
- httpEquiv: "X-UA-Compatible",
184
- content: "IE=edge"
185
- }), React.createElement("meta", {
186
- name: "viewport",
187
- content: "width=device-width, initial-scale=1"
188
- }), React.createElement("title", null, relPath), React.createElement(Reset, null), React.createElement("style", {
189
- dangerouslySetInnerHTML: {
190
- __html: contentStyles
191
- }
192
- })), React.createElement("body", {
193
- style: Styles.body
194
- }, React.createElement("div", {
195
- style: Styles.wrapper
196
- }, React.createElement(Header, {
197
- relPath: relPath,
198
- basePath: options.basePath
199
- }), React.createElement("div", {
200
- className: "content",
201
- dangerouslySetInnerHTML: {
202
- __html: body
203
- }
204
- })), React.createElement(Footer, null)));
205
- };
206
- const renderMortyPage = (relPath, htmlBody, options) => ReactDOMServer.renderToString(React.createElement(MortyPage, {
207
- relPath: relPath,
208
- body: htmlBody,
209
- options: options
210
- }));
211
- module.exports = renderMortyPage;
@@ -1,26 +0,0 @@
1
- const path = require('path');
2
- const asciidoctor = require('asciidoctor')();
3
- const renderMortyPage = require('./page-renderers/MortyPage');
4
- const parseToHtml = require('./markdown-to-html-parser');
5
- const changeExtension = relPath => relPath.replace(/\.[^.]*$/, '.html'); // \.[^.]*$ selects everything from end of string to first '.' character including the '.'
6
-
7
- const convertToHtml = ({
8
- relativePath,
9
- raw
10
- }, options) => {
11
- const textString = raw.toString();
12
- const ext = path.extname(relativePath);
13
- if (ext === '.asciidoc' || ext === '.adoc' || ext === '.asc') {
14
- return asciidoctor.convert(textString);
15
- }
16
- return parseToHtml(textString, options);
17
- };
18
- const transformContent = (inputObj, options) => {
19
- const inputRelPath = inputObj.relativePath;
20
- const html = convertToHtml(inputObj, options);
21
- return {
22
- relativePath: changeExtension(inputRelPath),
23
- raw: renderMortyPage(inputRelPath, html, options)
24
- };
25
- };
26
- module.exports = transformContent;
@@ -1,24 +0,0 @@
1
- const path = require('path');
2
- const transformContent = require('./transform-content');
3
- const generateIndexes = require('./generate-indexes');
4
- const validate = inputObjs => {
5
- if (!Array.isArray(inputObjs)) throw new Error('First arg to transform() must be an array');
6
- inputObjs.map(inputObj => {
7
- if (typeof inputObj.raw === 'undefined') throw new Error('All objects in input array must have a .raw property');
8
- if (typeof inputObj.relativePath === 'undefined') throw new Error('All objects in input array must have a .relativePath property');
9
- });
10
- };
11
- const transform = (inputObjs, options) => {
12
- validate(inputObjs);
13
- const contentObjs = inputObjs.map(inputObj => {
14
- const ext = path.extname(inputObj.relativePath);
15
- if (ext === '.md' || ext === '.asciidoc' || ext === '.adoc' || ext === '.asc') {
16
- return transformContent(inputObj, options);
17
- } else {
18
- return inputObj;
19
- }
20
- });
21
- const indexObjs = generateIndexes(contentObjs, options);
22
- return [...contentObjs, ...indexObjs];
23
- };
24
- module.exports = transform;