@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/docs-theme",
3
- "version": "1.0.132",
3
+ "version": "1.0.133",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "files": [
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(`${p}/changelog.md`, updateChangelog(markdown));
43
+ fs.writeFileSync(path.join(p, 'changelog.md'), updateChangelog(markdown));
44
44
  });
45
45
  }
46
46
 
47
- function copyChangelogFromRoot(paths) {
48
- const changelogPath = findPathInParentOrThrow('CHANGELOG.md');
47
+ function copyChangelogFromRoot(paths, hasDefaultChangelog) {
48
+ const sourceChangelogPath = findPathInParentOrThrow('CHANGELOG.md');
49
49
 
50
50
  for (const docsPath of paths) {
51
- if (fs.existsSync(path.join(docsPath, 'changelog.md')) && fs.statSync(
52
- path.join(docsPath, 'changelog.md')).mtime >= fs.statSync(changelogPath).mtime) continue;
53
- const changelog = fs.readFileSync(changelogPath, 'utf-8');
54
- fs.writeFileSync(`${docsPath}/changelog.md`, updateChangelog(changelog));
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
- if (options.changelogFromRoot) {
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
- }