@apify/docs-theme 1.0.131 → 1.0.132
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/markdown.js +15 -6
- package/src/theme.js +7 -7
package/package.json
CHANGED
package/src/markdown.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
function updateChangelog(changelog) {
|
|
2
|
-
changelog =
|
|
2
|
+
changelog = addFrontmatter(changelog);
|
|
3
3
|
changelog = pushHeadings(changelog);
|
|
4
|
-
changelog =
|
|
5
|
-
changelog =
|
|
4
|
+
changelog = fixUserLinks(changelog);
|
|
5
|
+
changelog = fixPRLinks(changelog);
|
|
6
|
+
changelog = escapeMDXCharacters(changelog);
|
|
6
7
|
return changelog;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
function
|
|
10
|
+
function addFrontmatter(changelog, header = 'Changelog') {
|
|
10
11
|
return `---
|
|
11
12
|
title: ${header}
|
|
12
13
|
sidebar_label: ${header}
|
|
@@ -19,14 +20,22 @@ function pushHeadings(changelog) {
|
|
|
19
20
|
return changelog.replaceAll(/\n#[^#]/g, '\n## ');
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
function
|
|
23
|
+
function fixUserLinks(changelog) {
|
|
23
24
|
return changelog.replaceAll(/by @([a-zA-Z0-9-]+)/g, 'by [@$1](https://github.com/$1)');
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
function
|
|
27
|
+
function fixPRLinks(changelog) {
|
|
27
28
|
return changelog.replaceAll(/(((https?:\/\/)?(www.)?)?github.com\/[^\s]*?\/pull\/([0-9]+))/g, '[#$5]($1)');
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
function escapeMDXCharacters(changelog) {
|
|
32
|
+
return changelog.replaceAll(/<|>/g, (match) => {
|
|
33
|
+
return match === '<' ? '<' : '>';
|
|
34
|
+
}).replaceAll(/\{|\}/g, (match) => {
|
|
35
|
+
return match === '{' ? '{' : '}';
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
30
39
|
module.exports = {
|
|
31
40
|
updateChangelog,
|
|
32
41
|
};
|
package/src/theme.js
CHANGED
|
@@ -25,7 +25,7 @@ function findPathInParentOrThrow(endPath) {
|
|
|
25
25
|
return filePath;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async function
|
|
28
|
+
async function generateChangelogFromGitHubReleases(paths, repo) {
|
|
29
29
|
const response = await axios.get(`https://api.github.com/repos/${repo}/releases`);
|
|
30
30
|
const releases = response.data;
|
|
31
31
|
|
|
@@ -81,6 +81,12 @@ function theme(
|
|
|
81
81
|
),
|
|
82
82
|
];
|
|
83
83
|
|
|
84
|
+
if (options.changelogFromRoot) {
|
|
85
|
+
copyChangelogFromRoot(pathsToCopyChangelog);
|
|
86
|
+
} else {
|
|
87
|
+
await generateChangelogFromGitHubReleases(pathsToCopyChangelog, `${context.siteConfig.organizationName}/${context.siteConfig.projectName}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
84
90
|
for (const p of pathsToCopyChangelog) {
|
|
85
91
|
// the changelog page has to exist for the sidebar to work - async loadContent() is (apparently) not awaited for by sidebar
|
|
86
92
|
if (fs.existsSync(path.join(p, 'changelog.md'))) continue;
|
|
@@ -92,12 +98,6 @@ It seems that the changelog is not available.
|
|
|
92
98
|
This either means that your Docusaurus setup is misconfigured, or that your GitHub repository contains no releases yet.
|
|
93
99
|
`);
|
|
94
100
|
}
|
|
95
|
-
|
|
96
|
-
if (options.changelogFromRoot) {
|
|
97
|
-
copyChangelogFromRoot(pathsToCopyChangelog);
|
|
98
|
-
} else {
|
|
99
|
-
await copyChangelogFromReleases(pathsToCopyChangelog, `${context.siteConfig.organizationName}/${context.siteConfig.projectName}`);
|
|
100
|
-
}
|
|
101
101
|
} catch (e) {
|
|
102
102
|
// eslint-disable-next-line no-console
|
|
103
103
|
console.warn(`Changelog page could not be initialized: ${e.message}`);
|