-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(content-docs): version path & prefix configuration options #8737
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 cla@meta.com. 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! |
@@ -34,6 +34,8 @@ Accepted fields: | |||
| 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. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
? fileOrDir | ||
: `${pluginId}_${fileOrDir}`; | ||
} | ||
|
||
/** `[siteDir]/community_versioned_docs/version-1.0.0` */ | ||
/** `[versionPath]/[pluginId?]_versioned_docs/version-1.0.0` */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the following comment word.
versionPath -> (versionSiteDir or versionDir)
`version-${versionName}`, | ||
); | ||
} | ||
|
||
/** `[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the following comment word.
versionPath -> (versionSiteDir or versionDir)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 🤪
See https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-docs#ex-config
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-docs
plugin 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-path
with theversionPath
andversionPrefix
options 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
versionPath
type: string | undefined
default: undefined
versionPrefix
type: 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