mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-10 17:53:36 +02:00
Docs(refactor): refactor repo list creation logic.
Move all mapping into creation function.
This commit is contained in:
parent
4d61fa7edd
commit
4c750335e8
@ -7,11 +7,11 @@
|
|||||||
// should be used to create the slug.
|
// should be used to create the slug.
|
||||||
const readmeRepos = {
|
const readmeRepos = {
|
||||||
'unleash-client-rust': {
|
'unleash-client-rust': {
|
||||||
sidebarSdkName: 'Rust',
|
sidebarName: 'Rust',
|
||||||
},
|
},
|
||||||
// as an example of when you'd use both
|
// as an example of when you'd use both
|
||||||
// 'unleash-android-proxy-sdk': {
|
// 'unleash-android-proxy-sdk': {
|
||||||
// sidebarSdkName: 'Android',
|
// sidebarName: 'Android',
|
||||||
// slugName: 'android-proxy',
|
// slugName: 'android-proxy',
|
||||||
// },
|
// },
|
||||||
};
|
};
|
||||||
@ -19,7 +19,17 @@ const readmeRepos = {
|
|||||||
function getReadmeRepoData(filename) {
|
function getReadmeRepoData(filename) {
|
||||||
const repoName = filename.split('/')[0];
|
const repoName = filename.split('/')[0];
|
||||||
|
|
||||||
return readmeRepos[repoName] ?? { sdkName: repoName };
|
const repoData = readmeRepos[repoName];
|
||||||
|
|
||||||
|
const repoUrl = `https://github.com/Unleash/${repoName}`;
|
||||||
|
|
||||||
|
if (repoData) {
|
||||||
|
return {
|
||||||
|
repoUrl,
|
||||||
|
...repoData,
|
||||||
|
slugName: (repoData.slugName ?? repoData.sidebarName).toLowerCase(),
|
||||||
|
};
|
||||||
|
} else return { sidebarName: repoName, repoUrl };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {import('@docusaurus/types').DocusaurusConfig} */
|
/** @type {import('@docusaurus/types').DocusaurusConfig} */
|
||||||
@ -592,13 +602,11 @@ module.exports = {
|
|||||||
(repo) => `${repo}/main/README.md`,
|
(repo) => `${repo}/main/README.md`,
|
||||||
), // the file names to download
|
), // the file names to download
|
||||||
modifyContent: (filename, content) => {
|
modifyContent: (filename, content) => {
|
||||||
const data = getReadmeRepoData(filename);
|
const sdk = getReadmeRepoData(filename);
|
||||||
return {
|
return {
|
||||||
filename: `${(
|
filename: `${sdk.slugName}.md`,
|
||||||
data.slugName ?? data.sidebarSdkName
|
|
||||||
).toLowerCase()}.md`,
|
|
||||||
content: `---
|
content: `---
|
||||||
title: ${data.sidebarSdkName} SDK
|
title: ${sdk.sidebarName} SDK
|
||||||
---
|
---
|
||||||
|
|
||||||
${content}
|
${content}
|
||||||
|
Loading…
Reference in New Issue
Block a user