@bbc/morty-docs 1.10.0 → 1.11.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/README.md CHANGED
@@ -43,7 +43,7 @@ Morty Docs will generate a website listing an HTML page for each markdown file i
43
43
 
44
44
  To try it with markdown files from a custom directory
45
45
  ```bash
46
- npm start /absolute/path/to/custom/directory
46
+ mortyPath=/absolute/path/to/custom/directory npm start
47
47
  ```
48
48
 
49
49
  ## Use as a library
@@ -12,14 +12,14 @@ const generateIndex = (directory, filePaths, subDirPaths, options) => {
12
12
  const subDirLinks = subDirPaths.filter(dirPath => !dirPath.includes('/')).map(dirPath => ({
13
13
  link: `${dirPath}/index.html`,
14
14
  text: dirPath,
15
- iconClass: 'fas fa-folder-open'
15
+ iconName: 'folder'
16
16
  }));
17
17
  const fileLinks = filePaths.map(filePath => {
18
18
  const text = path.basename(filePath);
19
19
  return {
20
20
  link: encodeURIComponent(text),
21
21
  text,
22
- iconClass: 'fas fa-file-alt'
22
+ iconName: 'file'
23
23
  };
24
24
  });
25
25
  return renderIndexPage([...subDirLinks, ...fileLinks], options, directory);
@@ -1,38 +1,33 @@
1
1
  const React = require('react');
2
2
 
3
+ const {
4
+ prettyDate
5
+ } = require('./PrettyDate');
6
+
3
7
  const Styles = {
4
8
  footer: {
5
9
  bottom: '0',
6
10
  width: '100%',
7
11
  backgroundColor: '#f5f5f5',
8
- padding: '0 15px',
9
12
  boxSizing: 'border-box',
10
13
  minHeight: '25vh',
11
- position: 'relative'
12
- },
13
- footerContainer: {
14
- padding: '1em 0 2em 0'
14
+ position: 'relative',
15
+ textAlign: 'center',
16
+ padding: '1em 0 2em 0',
17
+ lineHeight: '1.5rem'
15
18
  },
16
- footerContent: {
17
- textAlign: 'center'
19
+ footerLink: {
20
+ color: '#337ab7'
18
21
  }
19
22
  };
20
23
 
21
24
  const Footer = () => {
22
25
  return React.createElement("footer", {
23
- style: Styles.footer,
24
- className: "footer"
25
- }, React.createElement("div", {
26
- style: Styles.footerContainer,
27
- className: "container"
28
- }, React.createElement("div", {
29
- className: "row"
30
- }, React.createElement("div", {
31
- style: Styles.footerContent,
32
- className: "col-md-4 col-md-offset-4"
33
- }, React.createElement("p", null, React.createElement("a", {
34
- href: "https://github.com/bbc/morty-docs"
35
- }, "Morty-Docs on github"), ".")))));
26
+ style: Styles.footer
27
+ }, React.createElement("a", {
28
+ href: "https://github.com/bbc/morty-docs",
29
+ style: Styles.footerLink
30
+ }, "Morty-Docs on github"), React.createElement("br", null), "Page generated on ", prettyDate(new Date()));
36
31
  };
37
32
 
38
33
  module.exports = Footer;
@@ -7,23 +7,21 @@ const Styles = {
7
7
  border: 'none',
8
8
  borderRadius: '0',
9
9
  backgroundColor: '#000',
10
- height: '60px',
11
10
  marginBottom: '0',
12
- width: '100%',
13
- padding: '1.142rem'
11
+ width: '100%'
14
12
  },
15
13
  headerNav: {},
16
14
  headerLinks: {
17
- padding: '0',
15
+ padding: '1rem',
18
16
  listStyle: 'none',
19
17
  display: 'flex',
20
- height: '100%',
21
18
  alignItems: 'center'
22
19
  },
23
20
  headerLink: {
24
21
  textAlign: 'left',
25
22
  color: 'lightblue',
26
- fontSize: '2rem'
23
+ fontSize: '1.5rem',
24
+ textDecoration: 'none'
27
25
  },
28
26
  separator: {
29
27
  margin: '0 0.28rem',
@@ -51,15 +49,16 @@ const HeaderLinks = ({
51
49
  const Header = ({
52
50
  relPath,
53
51
  basePath
54
- }) => React.createElement("div", {
55
- className: "container",
56
- style: Styles.navbar
57
- }, React.createElement("nav", {
58
- style: Styles.headerNav
59
- }, React.createElement("ol", {
60
- style: Styles.headerLinks
61
- }, React.createElement(HeaderLinks, {
62
- paths: getHeaderPaths(basePath, relPath)
63
- }))));
52
+ }) => {
53
+ return React.createElement("div", {
54
+ style: Styles.navbar
55
+ }, React.createElement("nav", {
56
+ style: Styles.headerNav
57
+ }, React.createElement("ol", {
58
+ style: Styles.headerLinks
59
+ }, React.createElement(HeaderLinks, {
60
+ paths: getHeaderPaths(basePath, relPath)
61
+ }))));
62
+ };
64
63
 
65
64
  module.exports = Header;
@@ -1,29 +1,63 @@
1
1
  const React = require('react');
2
2
 
3
+ const IconFileLines = require('./icons/IconFileLines');
4
+
5
+ const IconFolderOpen = require('./icons/IconFolderOpen');
6
+
3
7
  const Styles = {
4
8
  indexListItem: {
5
- fontSize: '1.6em',
9
+ fontSize: '1.5rem',
6
10
  borderBottom: 'solid black 1px',
7
- marginBottom: '10px'
11
+ marginBottom: '1rem',
12
+ paddingBottom: '0.5rem'
8
13
  },
9
14
  linkText: {
10
- marginLeft: '5px'
15
+ marginLeft: '1rem'
16
+ },
17
+ linkAnchor: {
18
+ textDecoration: 'none',
19
+ color: '#337ab7'
20
+ },
21
+ icon: {
22
+ fill: '#337ab7',
23
+ height: '1em',
24
+ verticalAlign: 'middle'
25
+ },
26
+ iconWrap: {
27
+ display: 'inline-block',
28
+ width: '1em'
11
29
  }
12
30
  };
13
31
 
32
+ const Icon = ({
33
+ iconName
34
+ }) => {
35
+ if (iconName === 'folder') {
36
+ return React.createElement(IconFolderOpen, {
37
+ style: Styles.icon
38
+ });
39
+ }
40
+
41
+ return React.createElement(IconFileLines, {
42
+ style: Styles.icon
43
+ });
44
+ };
45
+
14
46
  const IndexListItem = ({
15
47
  link,
16
48
  text,
17
- iconClass
49
+ iconName
18
50
  }) => {
19
51
  return React.createElement("li", {
20
- className: "index-list",
21
52
  style: Styles.indexListItem
22
53
  }, React.createElement("a", {
23
- href: link
24
- }, React.createElement("i", {
25
- className: iconClass
26
- }), React.createElement("span", {
54
+ href: link,
55
+ style: Styles.linkAnchor
56
+ }, React.createElement("span", {
57
+ style: Styles.iconWrap
58
+ }, React.createElement(Icon, {
59
+ iconName: iconName
60
+ })), React.createElement("span", {
27
61
  style: Styles.linkText
28
62
  }, text)));
29
63
  };
@@ -0,0 +1,31 @@
1
+ const React = require('react');
2
+
3
+ const nth = function (d) {
4
+ if (d > 3 && d < 21) return 'th';
5
+
6
+ switch (d % 10) {
7
+ case 1:
8
+ return 'st';
9
+
10
+ case 2:
11
+ return 'nd';
12
+
13
+ case 3:
14
+ return 'rd';
15
+
16
+ default:
17
+ return 'th';
18
+ }
19
+ };
20
+
21
+ const month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
22
+
23
+ const prettyDate = dateObj => {
24
+ const day = dateObj.getDate();
25
+ const year = dateObj.getFullYear();
26
+ return React.createElement(React.Fragment, null, day, React.createElement("sup", null, nth(day)), " ", month[dateObj.getMonth()], " ", year);
27
+ };
28
+
29
+ module.exports = {
30
+ prettyDate
31
+ };
@@ -0,0 +1,64 @@
1
+ const React = require('react');
2
+
3
+ const resetStyles = `/* http://meyerweb.com/eric/tools/css/reset/
4
+ v2.0 | 20110126
5
+ License: none (public domain)
6
+ */
7
+
8
+ html, body, div, span, applet, object, iframe,
9
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
10
+ a, abbr, acronym, address, big, cite, code,
11
+ del, dfn, em, img, ins, kbd, q, s, samp,
12
+ small, strike, strong, sub, sup, tt, var,
13
+ b, u, i, center,
14
+ dl, dt, dd, ol, ul, li,
15
+ fieldset, form, label, legend,
16
+ table, caption, tbody, tfoot, thead, tr, th, td,
17
+ article, aside, canvas, details, embed,
18
+ figure, figcaption, footer, header, hgroup,
19
+ menu, nav, output, ruby, section, summary,
20
+ time, mark, audio, video {
21
+ margin: 0;
22
+ padding: 0;
23
+ border: 0;
24
+ font-size: 100%;
25
+ font: inherit;
26
+ vertical-align: baseline;
27
+ }
28
+ /* HTML5 display-role reset for older browsers */
29
+ article, aside, details, figcaption, figure,
30
+ footer, header, hgroup, menu, nav, section {
31
+ display: block;
32
+ }
33
+ body {
34
+ line-height: 1;
35
+ }
36
+ ol, ul {
37
+ list-style: none;
38
+ }
39
+ blockquote, q {
40
+ quotes: none;
41
+ }
42
+ blockquote:before, blockquote:after,
43
+ q:before, q:after {
44
+ content: '';
45
+ content: none;
46
+ }
47
+ table {
48
+ border-collapse: collapse;
49
+ border-spacing: 0;
50
+ }
51
+ sup {
52
+ vertical-align: super;
53
+ font-size: smaller;
54
+ padding-right: 0.2rem;
55
+ }
56
+ `;
57
+
58
+ const Reset = () => React.createElement("style", {
59
+ dangerouslySetInnerHTML: {
60
+ __html: resetStyles
61
+ }
62
+ });
63
+
64
+ module.exports = Reset;
@@ -2,7 +2,8 @@ const React = require('react');
2
2
 
3
3
  const Styles = {
4
4
  heading: {
5
- fontSize: '32px'
5
+ fontSize: '2rem',
6
+ fontWeight: '500'
6
7
  }
7
8
  };
8
9
 
@@ -11,10 +12,10 @@ const Title = ({
11
12
  }) => {
12
13
  if (contentTitle) {
13
14
  return React.createElement("div", {
14
- className: "row col-md-6 col-md-offset-3",
15
15
  style: {
16
16
  textAlign: 'center',
17
- marginBottom: '20px'
17
+ marginBottom: '20px',
18
+ marginTop: '32px'
18
19
  }
19
20
  }, React.createElement("h1", {
20
21
  style: Styles.heading
@@ -0,0 +1,14 @@
1
+ const React = require('react');
2
+
3
+ const IconFileLines = ({
4
+ style
5
+ }) => React.createElement("svg", {
6
+ "aria-hidden": "true",
7
+ style: style,
8
+ xmlns: "http://www.w3.org/2000/svg",
9
+ viewBox: "0 0 384 512"
10
+ }, '<!--! Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. -->', React.createElement("path", {
11
+ d: "M256 0v128h128L256 0zM224 128L224 0H48C21.49 0 0 21.49 0 48v416C0 490.5 21.49 512 48 512h288c26.51 0 48-21.49 48-48V160h-127.1C238.3 160 224 145.7 224 128zM272 416h-160C103.2 416 96 408.8 96 400C96 391.2 103.2 384 112 384h160c8.836 0 16 7.162 16 16C288 408.8 280.8 416 272 416zM272 352h-160C103.2 352 96 344.8 96 336C96 327.2 103.2 320 112 320h160c8.836 0 16 7.162 16 16C288 344.8 280.8 352 272 352zM288 272C288 280.8 280.8 288 272 288h-160C103.2 288 96 280.8 96 272C96 263.2 103.2 256 112 256h160C280.8 256 288 263.2 288 272z"
12
+ }));
13
+
14
+ module.exports = IconFileLines;
@@ -0,0 +1,14 @@
1
+ const React = require('react');
2
+
3
+ const IconFolderOpen = ({
4
+ style
5
+ }) => React.createElement("svg", {
6
+ "aria-hidden": "true",
7
+ style: style,
8
+ xmlns: "http://www.w3.org/2000/svg",
9
+ viewBox: "0 0 576 512"
10
+ }, '<!--! Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. -->', React.createElement("path", {
11
+ d: "M147.8 192H480V144C480 117.5 458.5 96 432 96h-160l-64-64h-160C21.49 32 0 53.49 0 80v328.4l90.54-181.1C101.4 205.6 123.4 192 147.8 192zM543.1 224H147.8C135.7 224 124.6 230.8 119.2 241.7L0 480h447.1c12.12 0 23.2-6.852 28.62-17.69l96-192C583.2 249 567.7 224 543.1 224z"
12
+ }));
13
+
14
+ module.exports = IconFolderOpen;
@@ -1,4 +1,4 @@
1
- function _extends() { _extends = Object.assign || 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); }
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
2
 
3
3
  const React = require('react');
4
4
 
@@ -12,6 +12,8 @@ const Footer = require('./Components/Footer');
12
12
 
13
13
  const IndexListItem = require('./Components/IndexListItem');
14
14
 
15
+ const Reset = require('./Components/Reset');
16
+
15
17
  const Styles = {
16
18
  headingContainer: {
17
19
  padding: '40px 15px',
@@ -32,10 +34,19 @@ const Styles = {
32
34
  paddingBottom: '20px'
33
35
  },
34
36
  html: {
35
- minHeight: '100vh'
37
+ minHeight: '100vh',
38
+ fontSize: '16px'
36
39
  },
37
40
  body: {
38
- minHeight: '100vh'
41
+ minHeight: '100vh',
42
+ fontFamily: '"Helvetica Neue",Helvetica,Arial,sans-serif',
43
+ color: '#333',
44
+ backgroundColor: '#fff'
45
+ },
46
+ listContainer: {
47
+ marginTop: '10px',
48
+ maxWidth: '600px',
49
+ margin: 'auto'
39
50
  }
40
51
  };
41
52
 
@@ -55,17 +66,7 @@ const IndexPage = ({
55
66
  }), React.createElement("meta", {
56
67
  name: "viewport",
57
68
  content: "width=device-width, initial-scale=1"
58
- }), React.createElement("title", null, `Morty Docs`), React.createElement("link", {
59
- rel: "stylesheet",
60
- href: "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css",
61
- integrity: "sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u",
62
- crossOrigin: "anonymous"
63
- }), React.createElement("link", {
64
- rel: "stylesheet",
65
- href: "https://use.fontawesome.com/releases/v5.8.1/css/all.css",
66
- integrity: "sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf",
67
- crossOrigin: "anonymous"
68
- })), React.createElement("body", {
69
+ }), React.createElement("title", null, `Morty Docs`), React.createElement(Reset, null)), React.createElement("body", {
69
70
  style: Styles.body
70
71
  }, React.createElement("div", {
71
72
  style: Styles.wrapper
@@ -73,17 +74,14 @@ const IndexPage = ({
73
74
  relPath: relPath,
74
75
  basePath: options.basePath
75
76
  }), React.createElement("div", {
76
- className: "container",
77
77
  style: {
78
78
  marginTop: '10px'
79
79
  }
80
80
  }, React.createElement(Title, {
81
81
  contentTitle: options.contentTitle
82
82
  }), React.createElement("div", {
83
- className: "row col-md-8 col-md-offset-2"
84
- }, React.createElement("ul", {
85
- className: "list-unstyled"
86
- }, (() => listItems.map((item, index) => React.createElement(IndexListItem, _extends({
83
+ style: Styles.listContainer
84
+ }, React.createElement("ul", null, (() => listItems.map((item, index) => React.createElement(IndexListItem, _extends({
87
85
  key: index
88
86
  }, item))))())))), React.createElement(Footer, null)));
89
87
  };
@@ -6,18 +6,174 @@ const Header = require('./Components/Header');
6
6
 
7
7
  const Footer = require('./Components/Footer');
8
8
 
9
+ const Reset = require('./Components/Reset');
10
+
9
11
  const Styles = {
10
12
  wrapper: {
11
13
  minHeight: '75vh',
12
14
  paddingBottom: '20px'
13
15
  },
14
16
  html: {
15
- minHeight: '100vh'
17
+ minHeight: '100vh',
18
+ fontSize: '16px'
16
19
  },
17
20
  body: {
18
- minHeight: '100vh'
21
+ minHeight: '100vh',
22
+ fontFamily: '"Helvetica Neue",Helvetica,Arial,sans-serif',
23
+ color: '#333',
24
+ backgroundColor: '#fff'
19
25
  }
20
26
  };
27
+ const contentStyles = `
28
+ .content {
29
+ padding: 20px 96px;
30
+ line-height: 1.42857143;
31
+ max-width: 960px;
32
+ margin: 0 auto;
33
+ }
34
+
35
+ .content a {
36
+ color: #337ab7;
37
+ text-decoration: none;
38
+ }
39
+
40
+ .content h1 {
41
+ font-size: 2.2rem;
42
+ font-weight: 500;
43
+ margin-top: 20px;
44
+ margin-bottom: 10px;
45
+ }
46
+
47
+ .content h2 {
48
+ font-size: 1.8rem;
49
+ font-weight: 500;
50
+ margin-top: 20px;
51
+ margin-bottom: 10px;
52
+ }
53
+
54
+ .content h3 {
55
+ font-size: 1.5rem;
56
+ font-weight: 500;
57
+ margin-top: 20px;
58
+ margin-bottom: 10px;
59
+ }
60
+
61
+ .content ul {
62
+ display: block;
63
+ list-style-type: disc;
64
+ margin-block-start: 1em;
65
+ margin-block-end: 1em;
66
+ padding-inline-start: 40px;
67
+ margin-bottom: 10px;
68
+ }
69
+
70
+ .content ol {
71
+ list-style-type: decimal;
72
+ display: block;
73
+ margin-block-start: 1em;
74
+ margin-block-end: 1em;
75
+ padding-inline-start: 40px;
76
+ }
77
+
78
+ .content p {
79
+ margin-bottom: 10px;
80
+ }
81
+
82
+ .content img {
83
+ display: block;
84
+ max-width: 100%;
85
+ height: auto;
86
+ vertical-align: middle;
87
+ }
88
+
89
+ .content strong {
90
+ font-weight: 700;
91
+ }
92
+
93
+ .content em {
94
+ font-style: italic;
95
+ }
96
+
97
+ .content blockquote {
98
+ padding: 10px 20px;
99
+ margin: 0 0 20px;
100
+ font-size: 17.5px;
101
+ border-left: 5px solid #eee;
102
+ }
103
+
104
+ .content blockquote p:last-child {
105
+ margin-bottom: 0;
106
+ }
107
+
108
+ .content hr {
109
+ margin-top: 20px;
110
+ margin-bottom: 20px;
111
+ border: 0;
112
+ border-top: 1px solid #949494;
113
+ }
114
+
115
+ .content pre {
116
+ display: block;
117
+ padding: 9.5px;
118
+ margin: 0 0 10px;
119
+ font-size: 13px;
120
+ line-height: 1.42857143;
121
+ color: #333;
122
+ word-break: break-all;
123
+ word-wrap: break-word;
124
+ background-color: #f5f5f5;
125
+ border: 1px solid #ccc;
126
+ border-radius: 4px;
127
+ }
128
+
129
+ .content code {
130
+ font-family: Menlo,Monaco,Consolas,"Courier New",monospace;
131
+ }
132
+
133
+ .content pre code {
134
+ padding: 0;
135
+ font-size: inherit;
136
+ color: inherit;
137
+ white-space: pre-wrap;
138
+ background-color: transparent;
139
+ border-radius: 0;
140
+ }
141
+
142
+ .content p code {
143
+ padding: 2px 4px;
144
+ font-size: 90%;
145
+ color: #c7254e;
146
+ background-color: #f9f2f4;
147
+ border-radius: 4px;
148
+ }
149
+
150
+ .content table {
151
+ background-color: transparent;
152
+ border-spacing: 0;
153
+ border-collapse: collapse;
154
+ width: 100%;
155
+ max-width: 100%;
156
+ margin-bottom: 20px;
157
+ }
158
+
159
+ .content th {
160
+ text-align: left;
161
+ vertical-align: bottom;
162
+ border-bottom: 2px solid #ddd;
163
+ font-weight: bold;
164
+ font-size: 1.2rem;
165
+ padding: 8px;
166
+ line-height: 1.42857143;
167
+ }
168
+
169
+ .content td {
170
+ padding: 8px;
171
+ line-height: 1.42857143;
172
+ vertical-align: top;
173
+ border-top: 1px solid #ddd;
174
+ }
175
+
176
+ `;
21
177
 
22
178
  const MortyPage = ({
23
179
  relPath,
@@ -35,11 +191,10 @@ const MortyPage = ({
35
191
  }), React.createElement("meta", {
36
192
  name: "viewport",
37
193
  content: "width=device-width, initial-scale=1"
38
- }), React.createElement("title", null, relPath), React.createElement("link", {
39
- rel: "stylesheet",
40
- href: "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css",
41
- integrity: "sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u",
42
- crossOrigin: "anonymous"
194
+ }), React.createElement("title", null, relPath), React.createElement(Reset, null), React.createElement("style", {
195
+ dangerouslySetInnerHTML: {
196
+ __html: contentStyles
197
+ }
43
198
  })), React.createElement("body", {
44
199
  style: Styles.body
45
200
  }, React.createElement("div", {
@@ -48,7 +203,7 @@ const MortyPage = ({
48
203
  relPath: relPath,
49
204
  basePath: options.basePath
50
205
  }), React.createElement("div", {
51
- className: "container",
206
+ className: "content",
52
207
  dangerouslySetInnerHTML: {
53
208
  __html: body
54
209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbc/morty-docs",
3
- "version": "1.10.0",
3
+ "version": "1.11.2",
4
4
  "description": "To generate a static website from markdown documentation, to allow users to consume content in an easily accessible format",
5
5
  "main": "build/index.js",
6
6
  "publishConfig": {
@@ -53,7 +53,8 @@
53
53
  "@babel/node": "^7.4.5",
54
54
  "@babel/preset-react": "^7.0.0",
55
55
  "babel-eslint": "^10.0.3",
56
- "jest": "^24.7.1",
56
+ "http-server": "^14.1.1",
57
+ "jest": "^28.1.2",
57
58
  "jest-serializer-html": "^7.0.0",
58
59
  "standard": "^12.0.1"
59
60
  },