-
-
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
Output directory of versioning - {PLUGIN_INSTANCE_ID}_versioned-docs
should be configurable
#8061
Comments
Sounds reasonable. Thanks for the detailed writeup! This has been one of the best issue reports in a while 😄 |
Cool I'll work on it 👍 |
Hey @maxhr , sorry for the delay. To me, it is not necessarily the best idea to put the docs outside the site folder, and can lead to subtle bugs that might be surprising. MD docs are compiled to React components with MDX, so your content files ARE real components after being compiled. If your docs folder (or any folder containing md content) is outside your site, there's a risk it resolves the React dependency from a different This is more likely to happen in monorepo setups, see #8091 (comment) Note that if your content folder does not have any I'm not against implementing this but please be aware of the limitations of what you want to do. Adding Can you explain more of your motivations to move the docs structure outside of the site, and to be able to configure folder with that level of granularity? |
I don't know why it is necessary to put it outside but i agree that it is necessary to modify the root path of a docs folder. maxhr described it as With the
|
@Jersyfi , I agree with your point. Currently, I am maintaining a single |
@GM1957 Thank you for the information. Your work will also help shrinking the 'docusaurus.config.js' file. Thinking more about my point I think it would be the best to reorganize the structure in the future and for now just to make the path configurable. As a example at the moment for doc-1 the folders are named doc-1_... too but when the docs are in the same folder this isn't needed anymore. I hope it is understandable what I mean. When you have something new just let me know and I need to say that you are doing a great job so far with docusaurus. |
Thank you @Jersyfi. Currently is there any way to have |
@GM1957 as i could figure it our it is not possible. I looked at the documentation and the code and these files need to be placed in the root level of the project. |
@Jersyfi currently I am trying to achieve a modular structure for my use case because this versions and all will be handled through pipeline, in more of a automated way. so how to move forward with this issue ? |
@GM1957 for the v2 version of docusaurus i think it is the best way to add a Are you able to add this variable to the code structure? Because i would need some time to understand the code structure in order to implement
|
The way I understand it, you'd like to have something like this: website/
├─ ios/
│ ├─ docs/
│ ├─ versioned_docs/
│ ├─ versions.json
├─ android/
│ ├─ docs/
│ ├─ versioned_docs/
│ ├─ versions.json For retrocompatibility reasons it's likely that we'll have to keep the longer folder name If we want shorter names we need more than just I don't have time to work on this feature now but if someone want to do a proper RFC/design proposal and submit a PR I'd be happy to have this |
@slorber perfekt that you agree with it. You are right that this needs |
@slorber correct, but as I can understand this
plugin config will look like
For this config, system should look for versioned_docs, versioned_sidebars in
I think this will give us more flexibility and customization options, maybe we can take this as a bug. |
I don't know, that feels quite implicit to me and not so flexible. I'd prefer if Instead of ios-docs/next
ios-docs/v1.0
ios-docs/v2.0
ios-docs/v3.0 [
"@docusaurus/plugin-content-docs",
{
id: "ios",
path: "./ios-docs/next",
versionedPath: ({version}) => `./ios/docs/docs/v${version}`,
},
]; I think the above use-case is a legit docs fs structure so we should allow users to be able to achieve that easily, and even more fancy patterns. We could even avoid the |
@slorber yesterday i looked at the code and it is possible to keep the flexebility up running. I will provide a PR and you can take a look at it. |
@slorber then i will keep up the discussion here 👌 Firstly, I would like to comment on your comment about If I understand your code comment correctly, the following configuration will result in the following code. Right? It would be great if you could describe your file structure in detail so that I know what your requirements are. [
"@docusaurus/plugin-content-docs",
{
id: "ios",
path: "./ios-docs/v-next",
versionPath: ({version}) => `./ios-docs/v-${version.toLowerCase().replace(".","-"}`,
},
]; website/
├─ ios-docs/
│ ├─ v-next/
│ ├─ v-1-0-0/
│ ├─ // versioned siderbars?
│ ├─ versions.json
│ ├─ sidebar.json With In the following example i describe you what changed with the configurration option. Note that i replaced [
"@docusaurus/plugin-content-docs",
{
id: "ios",
path: "./ios-docs/docs",
useVersionPrefix: false,
},
]; website/
├─ ios-docs/
│ ├─ docs/
│ ├─ versioned_docs/ // instead of `ios_versioned_docs`
│ ├─ versioned_sidebars/ // instead of `ios_versioned_sidebars`
│ ├─ versions.json
│ ├─ sidebar.json I have already noticed the confusion between route path and fs path, but it is understandable once you get it 😂. |
Actually forgot that we also need Docusaurus to know where to read/write the sidebar files. In the future, I'd like to get rid of the What I don't like with your solution is that:
Considering I'd like to get rid of the What I mean: module.exports = {
plugins: [
[
'@docusaurus/plugin-content-docs',
{
path: 'docs', (actually ignored => we configure paths for each version independently)
versions: {
current: {
path: 'ios-docs/v-next',
sidebarPath: 'ios-docs/v-next/sidebar.js'
},
'2.0.0': {
path: 'ios-docs/v-2.0.0',
sidebarPath: 'ios-docs/v-2.0.0/sidebar.js'
},
'1.0.0': {
path: 'ios-docs/v-1.0.0',
sidebarPath: 'ios-docs/v-1.0.0/sidebar.js'
},
},
},
],
],
}; Does it make sense? If you don't want to define paths for each version, you can use Node.js code and your own conversion to compute the value for |
@slorber your new folder structure makes sense. But i think that it is better to define it only once for all versions as you already wrote in an example. [
"@docusaurus/plugin-content-docs",
{
id: "ios",
path: "./ios-docs/next",
versionedPath: ({version}) => `./ios/docs/docs/v${version}`,
},
]; |
Hey @Jersyfi , is there any update regarding the mentioned PR? |
Have you read the Contributing Guidelines on issues?
Description
I want to organize the project to place the docs Markdown directories outside of Docusaurus root. .
I configure docs location in
docusaurus.config.js
:To tag and create a copy of the current version I run
docusaurus docs:version v2
It creates the versions in Docusaurus root, and I can't configure it otherwise.
It makes sense to have
versions.json
in Docusaurus root as it is a configuration file, but the actual Markdowns should at least consider the configured location of the other Markdowns, or be configurable.Has this been requested on Canny?
No response
Motivation
It's reasonable to assume that all files input and output entires would be configurable.
It makes sense that
versions.json
and{PLUGIN_INSTANCE_ID}_versions.json
to reside in Docusaurus root, as it is configuration, but placing copies of docs (which can be huge) upon every version tagging in root it not acceptable. I might want to have them in a separate repo.This is solvable with symlinks, but that's just fragile and doesn't always 100% work.
API design
Implementation probably should adjust this
getVersionDocsDirPath
function:https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-plugin-content-docs/src/versions/files.ts#L32
Default unconfigured behaviour
Keep it as it is now, create versioned content in Docusaurus root.
Configurable for all versions
The user should have an setting
versionedDocsPath
.Running
docusaurus docs:version v2
should produce the tree below.versions.json
is in Docusaurus root, the versioned copy is under../my-vers-outside
Even more configurable for each version separately
Config type
VersionConfig
should have an additional (optional) property. It should be namedpath
to be consistent with otherpath
s that set the directories' location, butVersionConfig.path
is already in use for URL path.Ideally that current
path
should be namedroutePath
andpath
to be used for directory path, but it's a breaking change, so maybe it can be calledversionedDocsPath
to be clear it overrides the defaultversionedDocsPath
.Running the tagging script will still output files in directory configured under
docs.versionedDocsPath
.Then the user can manually move the files and set
versionedDocsPath
for specific versions separately.Multi intstance configuration
Project structure:
docusaurus.config.js
:After running
docusaurus docs:version:my-instance-id v2
, file tree:To customize
v2
directory the user should move files manually.Say we make more versions
v3
andv4
:docusaurus docs:version:my-instance-id v3 && docusaurus docs:version:my-instance-id v4
.After tagging, manually moving files around and configuring the versions, result may look like this:
docusaurus.config.js
:Have you tried building it?
No response
Self-service
The text was updated successfully, but these errors were encountered: