@apify/docs-theme 1.0.132 → 1.0.133
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 +1 -1
- package/src/theme.js +21 -12
- package/src/theme/MDXComponents/Pre.js +0 -14
package/package.json
CHANGED
package/src/theme.js
CHANGED
|
@@ -40,18 +40,24 @@ async function generateChangelogFromGitHubReleases(paths, repo) {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
paths.forEach((p) => {
|
|
43
|
-
fs.writeFileSync(
|
|
43
|
+
fs.writeFileSync(path.join(p, 'changelog.md'), updateChangelog(markdown));
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
function copyChangelogFromRoot(paths) {
|
|
48
|
-
const
|
|
47
|
+
function copyChangelogFromRoot(paths, hasDefaultChangelog) {
|
|
48
|
+
const sourceChangelogPath = findPathInParentOrThrow('CHANGELOG.md');
|
|
49
49
|
|
|
50
50
|
for (const docsPath of paths) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
const targetChangelogPath = path.join(docsPath, 'changelog.md');
|
|
52
|
+
|
|
53
|
+
if (fs.existsSync(targetChangelogPath)
|
|
54
|
+
&& fs.statSync(targetChangelogPath).mtime >= fs.statSync(sourceChangelogPath).mtime
|
|
55
|
+
&& !hasDefaultChangelog.get(docsPath)) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const changelog = fs.readFileSync(sourceChangelogPath, 'utf-8');
|
|
60
|
+
fs.writeFileSync(targetChangelogPath, updateChangelog(changelog));
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
|
|
@@ -81,11 +87,7 @@ function theme(
|
|
|
81
87
|
),
|
|
82
88
|
];
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
copyChangelogFromRoot(pathsToCopyChangelog);
|
|
86
|
-
} else {
|
|
87
|
-
await generateChangelogFromGitHubReleases(pathsToCopyChangelog, `${context.siteConfig.organizationName}/${context.siteConfig.projectName}`);
|
|
88
|
-
}
|
|
90
|
+
const hasDefaultChangelog = new Map();
|
|
89
91
|
|
|
90
92
|
for (const p of pathsToCopyChangelog) {
|
|
91
93
|
// the changelog page has to exist for the sidebar to work - async loadContent() is (apparently) not awaited for by sidebar
|
|
@@ -97,6 +99,13 @@ sidebar_label: Changelog
|
|
|
97
99
|
It seems that the changelog is not available.
|
|
98
100
|
This either means that your Docusaurus setup is misconfigured, or that your GitHub repository contains no releases yet.
|
|
99
101
|
`);
|
|
102
|
+
hasDefaultChangelog.set(p, true);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (options.changelogFromRoot) {
|
|
106
|
+
copyChangelogFromRoot(pathsToCopyChangelog, hasDefaultChangelog);
|
|
107
|
+
} else {
|
|
108
|
+
await generateChangelogFromGitHubReleases(pathsToCopyChangelog, `${context.siteConfig.organizationName}/${context.siteConfig.projectName}`);
|
|
100
109
|
}
|
|
101
110
|
} catch (e) {
|
|
102
111
|
// eslint-disable-next-line no-console
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import CodeBlock from '@theme/CodeBlock';
|
|
2
|
-
import React, { isValidElement } from 'react';
|
|
3
|
-
|
|
4
|
-
export default function MDXPre(props) {
|
|
5
|
-
return (
|
|
6
|
-
<CodeBlock
|
|
7
|
-
// If this pre is created by a ``` fenced codeblock, unwrap the children
|
|
8
|
-
{...(isValidElement(props.children)
|
|
9
|
-
&& props.children.props?.originalType === 'code'
|
|
10
|
-
? props.children.props
|
|
11
|
-
: { ...props })}
|
|
12
|
-
/>
|
|
13
|
-
);
|
|
14
|
-
}
|