|
1 | 1 | /* eslint-disable global-require */ |
2 | | -const path = require('path'); |
| 2 | +const fs = require('node:fs'); |
| 3 | +const path = require('node:path'); |
3 | 4 |
|
4 | 5 | const { externalLinkProcessor } = require('./tools/utils/externalLink'); |
5 | 6 |
|
@@ -232,6 +233,35 @@ module.exports = { |
232 | 233 | }, |
233 | 234 | }; |
234 | 235 | }, |
| 236 | + // Copy root CHANGELOG.md to docs/ and all versioned_docs/ so every |
| 237 | + // doc version displays the same (latest) changelog — not a snapshot. |
| 238 | + function changelogFromRoot() { |
| 239 | + const sourceChangelog = path.join(__dirname, '..', 'CHANGELOG.md'); |
| 240 | + return { |
| 241 | + name: 'changelog-from-root', |
| 242 | + async loadContent() { |
| 243 | + if (!fs.existsSync(sourceChangelog)) return; |
| 244 | + |
| 245 | + const changelog = fs.readFileSync(sourceChangelog, 'utf-8'); |
| 246 | + const docsDir = path.join(__dirname, '..', 'docs'); |
| 247 | + const versionedDocsDir = path.join(__dirname, 'versioned_docs'); |
| 248 | + |
| 249 | + const targetDirs = [docsDir]; |
| 250 | + if (fs.existsSync(versionedDocsDir)) { |
| 251 | + for (const version of fs.readdirSync(versionedDocsDir)) { |
| 252 | + targetDirs.push(path.join(versionedDocsDir, version)); |
| 253 | + } |
| 254 | + } |
| 255 | + |
| 256 | + for (const dir of targetDirs) { |
| 257 | + fs.writeFileSync(path.join(dir, 'changelog.md'), changelog); |
| 258 | + } |
| 259 | + }, |
| 260 | + getPathsToWatch() { |
| 261 | + return [sourceChangelog]; |
| 262 | + }, |
| 263 | + }; |
| 264 | + }, |
235 | 265 | [ |
236 | 266 | path.resolve(__dirname, 'src/plugins/docusaurus-plugin-segment'), |
237 | 267 | { |
|
0 commit comments