docs: enhance autogenerate changelog configuration (#2289)
docs: enhance autogenerate changelog configuration
This commit is contained in:
commit
f4f1888468
@ -6,14 +6,13 @@ async function fetchData(siteConfig) {
|
|||||||
const repo = siteConfig.projectName;
|
const repo = siteConfig.projectName;
|
||||||
const apiUrl = `https://api.github.com/repos/${owner}/${repo}/releases`;
|
const apiUrl = `https://api.github.com/repos/${owner}/${repo}/releases`;
|
||||||
|
|
||||||
const outputDirectory = path.join(__dirname, '../../docs/guides/changelogs');
|
const outputDirectory = path.join(__dirname, '../../docs/releases/changelog');
|
||||||
|
|
||||||
if (!fs.existsSync(outputDirectory)) {
|
if (!fs.existsSync(outputDirectory)) {
|
||||||
fs.mkdirSync(outputDirectory);
|
fs.mkdirSync(outputDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
let counter = 1;
|
let counter = 1;
|
||||||
const categoryFilePath = path.join(outputDirectory, '_category_.json');
|
|
||||||
const cacheFilePath = path.join(outputDirectory, 'cache.json');
|
const cacheFilePath = path.join(outputDirectory, 'cache.json');
|
||||||
|
|
||||||
let cachedData = {};
|
let cachedData = {};
|
||||||
@ -83,7 +82,7 @@ async function fetchData(siteConfig) {
|
|||||||
|
|
||||||
const changes = release.body;
|
const changes = release.body;
|
||||||
|
|
||||||
let markdownContent = `---\nsidebar_position: ${counter}\n---\n# ${version}\n\nFor more details, [GitHub Issues](${releaseUrl})\n\nHighlighted Issue: ${issueLink}\n\n${changes}\n`;
|
let markdownContent = `---\nsidebar_position: ${counter}\nslug: /changelog/changelog-${version}\n---\n# ${version}\n\nFor more details, [GitHub Issues](${releaseUrl})\n\nHighlighted Issue: ${issueLink}\n\n${changes}\n`;
|
||||||
|
|
||||||
// Write to a separate markdown file for each version
|
// Write to a separate markdown file for each version
|
||||||
const outputFilePath = path.join(outputDirectory, `changelog-${version}.mdx`);
|
const outputFilePath = path.join(outputDirectory, `changelog-${version}.mdx`);
|
||||||
@ -93,20 +92,6 @@ async function fetchData(siteConfig) {
|
|||||||
|
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create _category_.json file
|
|
||||||
const categoryContent = {
|
|
||||||
label: 'Changelogs',
|
|
||||||
position: 5,
|
|
||||||
link: {
|
|
||||||
type: 'generated-index',
|
|
||||||
description: 'Changelog for Jan',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
fs.writeFileSync(categoryFilePath, JSON.stringify(categoryContent, null, 2), 'utf-8');
|
|
||||||
|
|
||||||
console.log(`_category_.json has been created at: ${categoryFilePath}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = fetchData;
|
module.exports = fetchData;
|
||||||
Loading…
x
Reference in New Issue
Block a user