@apify/docs-theme 1.0.19 → 1.0.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/docs-theme",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "files": [
@@ -17,7 +17,15 @@
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
19
  "@docusaurus/theme-common": "^2.2.0",
20
+ "@vcarl/remark-headings": "^0.1.0",
20
21
  "babel-loader": "^9.1.0",
21
- "prism-react-renderer": "^1.3.5"
22
+ "highlight.js": "^11.7.0",
23
+ "prism-react-renderer": "^1.3.5",
24
+ "react-markdown": "^8.0.4",
25
+ "rehype-highlight": "^6.0.0",
26
+ "remark-parse": "^10.0.1",
27
+ "remark-slug": "^7.0.1",
28
+ "remark-stringify": "^10.0.2",
29
+ "unified": "^10.1.2"
22
30
  }
23
31
  }
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+ import Layout from '@theme/Layout';
3
+ import ReactMarkdown from 'react-markdown';
4
+ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
5
+ import TOC from '@theme/TOC';
6
+ import TOCCollapsible from '@theme/TOCCollapsible';
7
+ import { useWindowSize } from '@docusaurus/theme-common';
8
+
9
+ import { unified } from 'unified';
10
+ import remarkSlug from 'remark-slug';
11
+ import remarkParse from 'remark-parse';
12
+ import remarkStringify from 'remark-stringify';
13
+ import remarkHeadings from '@vcarl/remark-headings';
14
+ import rehypeHighlight from 'rehype-highlight';
15
+ import dockerfile from 'highlight.js/lib/languages/dockerfile';
16
+
17
+ export default function ChangelogPage({ changelog }) {
18
+ const windowSize = useWindowSize();
19
+
20
+ const { data: { headings: tocRaw } } = unified()
21
+ .use(remarkParse)
22
+ .use(remarkStringify)
23
+ .use(remarkSlug)
24
+ .use(remarkHeadings)
25
+ .processSync(changelog);
26
+
27
+ const toc = tocRaw.map((x) => ({
28
+ value: x.value,
29
+ level: x.depth,
30
+ id: x.data.id,
31
+ }));
32
+
33
+ return (windowSize === 'desktop' || windowSize === 'ssr') ? (
34
+ <ChangelogPageDesktop {...{ changelog, toc }} />
35
+ ) : <ChangelogPageMobile {...{ changelog, toc }}/>;
36
+ }
37
+
38
+ function ChangelogPageDesktop({ changelog, toc }) {
39
+ const { siteConfig } = useDocusaurusContext();
40
+
41
+ return (
42
+ <Layout
43
+ title={`Changelog · ${siteConfig.tagline}`}
44
+ description={siteConfig.tagline}
45
+ >
46
+ <div className='docPage docMainContainer' style={{ margin: 'auto' }}>
47
+ <div className="row" style={{ flexWrap: 'nowrap' }}>
48
+ <div style={{ flexDirection: 'column' }} className='theme-doc-markdown markdown col--9'>
49
+ <ReactMarkdown
50
+ remarkPlugins={[remarkSlug]}
51
+ rehypePlugins={[
52
+ [rehypeHighlight,
53
+ {
54
+ languages: { dockerfile },
55
+ ignoreMissing: true,
56
+ },
57
+ ]]}
58
+ >
59
+ {changelog}
60
+ </ReactMarkdown>
61
+ </div>
62
+ <div className="col--3">
63
+ <TOC
64
+ {...{
65
+ toc,
66
+ minHeadingLevel: 1,
67
+ }}
68
+ />
69
+ </div>
70
+ </div>
71
+ </div>
72
+ </Layout>
73
+ );
74
+ }
75
+
76
+ function ChangelogPageMobile({ changelog, toc }) {
77
+ const { siteConfig } = useDocusaurusContext();
78
+
79
+ return (
80
+ <Layout
81
+ title={`Changelog · ${siteConfig.tagline}`}
82
+ description={siteConfig.tagline}
83
+ >
84
+ <div className='col apiItemCol' style={{ margin: 'auto' }}>
85
+ <TOCCollapsible
86
+ {...{
87
+ toc,
88
+ minHeadingLevel: 1,
89
+ }}
90
+ />
91
+ <div style={{ flexDirection: 'column' }} className='theme-doc-markdown markdown'>
92
+ <ReactMarkdown
93
+ remarkPlugins={[remarkSlug]}
94
+ >
95
+ {changelog}
96
+ </ReactMarkdown>
97
+ </div>
98
+ </div>
99
+ </Layout>
100
+ );
101
+ }
@@ -591,3 +591,27 @@ html[data-theme='dark'] .actionLink:hover::after {
591
591
  background-image: url('/img/arrow-right-primary.svg');
592
592
  margin-left: 8px;
593
593
  }
594
+
595
+
596
+ pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!
597
+ Theme: GitHub
598
+ Description: Light theme as seen on github.com
599
+ Author: github.com
600
+ Maintainer: @Hirse
601
+ Updated: 2021-05-15
602
+
603
+ Outdated base version: https://github.com/primer/github-syntax-light
604
+ Current colors taken from GitHub's CSS
605
+ */
606
+ .hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}
607
+
608
+ /*!
609
+ Theme: GitHub Dark Dimmed
610
+ Description: Dark dimmed theme as seen on github.com
611
+ Author: github.com
612
+ Maintainer: @Hirse
613
+ Updated: 2021-05-15
614
+
615
+ Colors taken from GitHub's CSS
616
+ */
617
+ html[data-theme="dark"] .hljs{color:#adbac7;background:#22272e}html[data-theme="dark"] .hljs-doctag,html[data-theme="dark"] .hljs-keyword,html[data-theme="dark"] .hljs-meta .hljs-keyword,html[data-theme="dark"] .hljs-template-tag,html[data-theme="dark"] .hljs-template-variable,html[data-theme="dark"] .hljs-type,html[data-theme="dark"] .hljs-variable.language_{color:#f47067}html[data-theme="dark"] .hljs-title,html[data-theme="dark"] .hljs-title.class_,html[data-theme="dark"] .hljs-title.class_.inherited__,html[data-theme="dark"] .hljs-title.function_{color:#dcbdfb}html[data-theme="dark"] .hljs-attr,html[data-theme="dark"] .hljs-attribute,html[data-theme="dark"] .hljs-literal,html[data-theme="dark"] .hljs-meta,html[data-theme="dark"] .hljs-number,html[data-theme="dark"] .hljs-operator,html[data-theme="dark"] .hljs-selector-attr,html[data-theme="dark"] .hljs-selector-class,html[data-theme="dark"] .hljs-selector-id,html[data-theme="dark"] .hljs-variable{color:#6cb6ff}html[data-theme="dark"] .hljs-meta .hljs-string,html[data-theme="dark"] .hljs-regexp,html[data-theme="dark"] .hljs-string{color:#96d0ff}html[data-theme="dark"] .hljs-built_in,html[data-theme="dark"] .hljs-symbol{color:#f69d50}html[data-theme="dark"] .hljs-code,html[data-theme="dark"] .hljs-comment,html[data-theme="dark"] .hljs-formula{color:#768390}html[data-theme="dark"] .hljs-name,html[data-theme="dark"] .hljs-quote,html[data-theme="dark"] .hljs-selector-pseudo,html[data-theme="dark"] .hljs-selector-tag{color:#8ddb8c}html[data-theme="dark"] .hljs-subst{color:#adbac7}html[data-theme="dark"] .hljs-section{color:#316dca;font-weight:700}html[data-theme="dark"] .hljs-bullet{color:#eac55f}html[data-theme="dark"] .hljs-emphasis{color:#adbac7;font-style:italic}html[data-theme="dark"] .hljs-strong{color:#adbac7;font-weight:700}html[data-theme="dark"] .hljs-addition{color:#b4f1b4;background-color:#1b4721}html[data-theme="dark"] .hljs-deletion{color:#ffd8d3;background-color:#78191b}
package/src/theme.js CHANGED
@@ -1,20 +1,58 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+
4
+ function findChangelogPath() {
5
+ let changelogPath = __dirname;
6
+ while (changelogPath !== path.join(changelogPath, '..')) {
7
+ const filePath = path.join(changelogPath, 'CHANGELOG.md');
8
+ if (fs.existsSync(filePath)) return filePath;
9
+ changelogPath = path.join(changelogPath, '..');
10
+ }
11
+ const filePath = path.join(changelogPath, 'CHANGELOG.md');
12
+ if (fs.existsSync(filePath)) return filePath;
13
+
14
+ throw new Error('Could not find CHANGELOG.md in any parent directory');
15
+ }
16
+
1
17
  function theme(
2
- context,
3
- options
18
+ context,
19
+ options,
4
20
  ) {
5
21
  return {
6
22
  name: '@apify/docs-theme',
23
+ getPathsToWatch() {
24
+ return ['./pages'];
25
+ },
7
26
  getThemePath() {
8
27
  return '../src/theme';
9
28
  },
10
29
  getTypeScriptThemePath() {
11
30
  return '../src/theme';
12
31
  },
13
- contentLoaded({ actions }) {
32
+ async contentLoaded({ actions }) {
14
33
  const { setGlobalData } = actions;
15
34
  setGlobalData({
16
35
  options,
17
36
  });
37
+
38
+ try {
39
+ const changelog = fs.readFileSync(findChangelogPath(), 'utf8');
40
+ const dataPath = await actions.createData(
41
+ 'changelog.json',
42
+ JSON.stringify(changelog),
43
+ );
44
+
45
+ actions.addRoute({
46
+ path: path.join(context.baseUrl, 'changelog'),
47
+ component: require.resolve('./pages/ChangelogPage.jsx'),
48
+ exact: true,
49
+ modules: {
50
+ changelog: dataPath,
51
+ },
52
+ });
53
+ } catch (e) {
54
+ console.warn(`Changelog page could not be initialized: ${e.message}`);
55
+ }
18
56
  },
19
57
  getClientModules() {
20
58
  return [
@@ -26,7 +64,7 @@ function theme(
26
64
  module: {
27
65
  rules: [
28
66
  {
29
- test: /(@apify\/|apify-)docs-theme\/src\/theme\/.*?\.jsx?$/,
67
+ test: /(@apify\/|apify-)docs-theme\/src\/(theme|pages)\/.*?\.jsx?$/,
30
68
  use: {
31
69
  loader: 'babel-loader',
32
70
  },