-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06cd27c
commit b888dbf
Showing
10 changed files
with
145 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// Helper function to get all files recursively from a directory | ||
function getAllFiles(dirPath, arrayOfFiles) { | ||
const files = fs.readdirSync(dirPath); | ||
|
||
arrayOfFiles = arrayOfFiles || []; | ||
|
||
files.forEach(function (file) { | ||
if (fs.statSync(path.join(dirPath, file)).isDirectory()) { | ||
arrayOfFiles = getAllFiles(path.join(dirPath, file), arrayOfFiles); | ||
} else { | ||
arrayOfFiles.push(path.join(dirPath, file)); | ||
} | ||
}); | ||
|
||
return arrayOfFiles; | ||
} | ||
|
||
module.exports = function (_context, _options) { | ||
return { | ||
name: 'custom-version-plugin', | ||
|
||
async loadContent() { | ||
// Read the versions.json file to get the list of versions | ||
const versionsJsonPath = path.join(_context.siteDir, 'versions.json'); | ||
const versions = JSON.parse(fs.readFileSync(versionsJsonPath, 'utf8')); | ||
|
||
// Read all the files in the /docs folder | ||
const docsPath = path.join(_context.siteDir, 'docs'); | ||
const files = getAllFiles(docsPath); | ||
|
||
// Iterate through the list of versions | ||
for (const version of versions) { | ||
const versionedDocsPath = path.join(_context.siteDir, 'versioned_docs', `version-${version}`); | ||
|
||
// Check if the version directory exists | ||
if (fs.existsSync(versionedDocsPath)) { | ||
// Iterate through the list of files in the /docs folder | ||
for (const file of files) { | ||
const relativePath = path.relative(docsPath, file); | ||
const customFilePath = path.join(versionedDocsPath, relativePath); | ||
|
||
// Check if the file exists in the version directory | ||
if (!fs.existsSync(customFilePath)) { | ||
// Create the directory if it doesn't exist | ||
fs.mkdirSync(path.dirname(customFilePath), { recursive: true }); | ||
|
||
// If the file doesn't exist, copy it from the /docs folder | ||
fs.copyFileSync(file, customFilePath); | ||
console.log(`Copied file from /docs to version-${version}:`, relativePath); | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +0,0 @@ | ||
{ | ||
"label": "Develop", | ||
"position": 0, | ||
"link": null | ||
} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"developSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "develop" | ||
} | ||
], | ||
"integrateSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "integrate" | ||
} | ||
], | ||
"userSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "user" | ||
} | ||
], | ||
"validateSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "validate" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"developSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "develop" | ||
} | ||
], | ||
"integrateSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "integrate" | ||
} | ||
], | ||
"userSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "user" | ||
} | ||
], | ||
"validateSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "validate" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"developSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "develop" | ||
} | ||
], | ||
"integrateSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "integrate" | ||
} | ||
], | ||
"userSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "user" | ||
} | ||
], | ||
"validateSidebar": [ | ||
{ | ||
"type": "autogenerated", | ||
"dirName": "validate" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
"0.47", | ||
"0.46", | ||
"0.45" | ||
] |