Repository navigation
Conversation
Added options to customize the path and the prefix of the versioned files
|
Hi @Jersyfi! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
⚡️ Lighthouse report for the deploy preview of this PR
|
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
| | Name | Type | Default | Description | | ||
| | --- | --- | --- | --- | | ||
| | `path` | `string` | `'docs'` | Path to the docs content directory on the file system, relative to site directory. | | ||
| | `versionPath` | `string` | `''` | Path to versioned files on filesystem, relative to site dir. | |
| } | ||
|
|
||
| /** `[siteDir]/community_versioned_docs/version-1.0.0` */ | ||
| /** `[versionPath]/[pluginId?]_versioned_docs/version-1.0.0` */ |
There was a problem hiding this comment.
Change the following comment word.
versionPath -> (versionSiteDir or versionDir)
| } | ||
|
|
||
| /** `[siteDir]/community_versioned_sidebars/version-1.0.0-sidebars.json` */ | ||
| /** `[versionPath]/[pluginId?]_versioned_sidebars/version-1.0.0-sidebars.json` */ |
There was a problem hiding this comment.
Change the following comment word.
versionPath -> (versionSiteDir or versionDir)
| /** `community` => `[siteDir]/community_versions.json` */ | ||
| export function getVersionsFilePath(siteDir: string, pluginId: string): string { | ||
| return path.join(siteDir, addPluginIdPrefix(VERSIONS_JSON_FILE, pluginId)); | ||
| /** `community` => `[versionPath]/community_versions.json` */ |
There was a problem hiding this comment.
Change the following comment word.
versionPath -> (versionSiteDir or versionDir)
There was a problem hiding this comment.
Looks like a good first draft
That probably solves your use-case, but I think this API is a bit awkward and not the most flexible either.
Reading the docs, it's not so clear to me what versionPrefix even is 😅
I'd prefer if we worked on designing the API we want first before doing the implementation.
For now, I think this API is more flexible than yours and less confusing:
[
"@docusaurus/plugin-content-docs",
{
id: "ios",
path: "./ios-docs/v-next",
versionPath: ({version}) => `./ios-docs/v-${version.toLowerCase().replace(".","-"}`,
},
];Note: we already have a version config map so we could also reuse it to allow configuring the fs path?
There's a bit of confusion between version route path and fs path unfortunately 🤪
module.exports = {
plugins: [
[
'@docusaurus/plugin-content-docs',
{
path: 'docs',
versions: {
current: {
path: 'ios-2.0.0',
},
'1.0.0': {
path: 'ios-1.0.0',
},
},
},
],
],
};We should discuss the tradeoffs of various design options we have (probably in the other issue so others can participate) and agree on something before implementing it.
|
Closing the PR as there is no time for further changes. |

Pre-flight checklist
Motivation
My personal motivation for modifying the
docusaurus-plugin-content-docsplugin is to have more flexibility in the file structure. With this feature it is possible to group all files in one folder without having them in the project root folder.Test Plan
I have added a test folder called
versioned-site-with-custom-pathwith theversionPathandversionPrefixoptions set and all files grouped together. In this state the tests are simple and I need your opinion if any changes are needed.Test links
Deploy preview: https://deploy-preview-8737--docusaurus-2.netlify.app/
Options
versionPathtype: string | undefined
default: undefined
versionPrefixtype: boolean
default: true
Mofified Documentation
Path: website/docs/api/plugins/plugin-content-docs.mdx
Deploy preview: https://deploy-preview-8737--docusaurus-2.netlify.app/docs/api/plugins/@docusaurus/plugin-content-docs/
Related issues/PRs
#8061