Skip to content

feat(content-docs): version path & prefix configuration options - #8737

Closed
Jersyfi wants to merge 4 commits into
meta:mainfrom
Jersyfi:main
Closed

Jersyfi wants to merge 4 commits into
meta:mainfrom
Jersyfi:main

Conversation

@Jersyfi

@Jersyfi Jersyfi commented Mar 5, 2023 •

Copy link
Copy Markdown

Pre-flight checklist

  • I have read the Contributing Guidelines on pull requests.
  • If this is a code change: I have written unit tests and/or added dogfooding pages to fully verify the new behavior.
  • If this is a new API or substantial change: the PR has an accompanying issue (closes #0000) and the maintainers have approved on my working plan.

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 the versionPath and versionPrefix options set and all files grouped together. In this state the tests are simple and I need your opinion if any changes are needed.

image

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

Jersyfi added 3 commits March 5, 2023 13:59
Added options to customize the path and the prefix of the versioned files
@facebook-github-bot

Copy link
Copy Markdown
Contributor

Hi @Jersyfi!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@netlify

netlify Bot commented Mar 5, 2023 •

Copy link
Copy Markdown

✅ [V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit d8d5810
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/64059a8602ce9a00087cc09e
😎 Deploy Preview https://deploy-preview-8737--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions

github-actions Bot commented Mar 5, 2023 •

Copy link
Copy Markdown

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟢 90 🟢 97 🟢 100 🟢 100 🟢 90 Report
/docs/installation 🟠 70 🟢 100 🟢 100 🟢 100 🟢 90 Report

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 6, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

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. |

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

Found that i missed changing the versionPath default value from '' to undefined.
image

}

/** `[siteDir]/community_versioned_docs/version-1.0.0` */
/** `[versionPath]/[pluginId?]_versioned_docs/version-1.0.0` */

@Jersyfi Jersyfi Mar 6, 2023 •

Copy link
Copy Markdown
Author

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)

}

/** `[siteDir]/community_versioned_sidebars/version-1.0.0-sidebars.json` */
/** `[versionPath]/[pluginId?]_versioned_sidebars/version-1.0.0-sidebars.json` */

@Jersyfi Jersyfi Mar 6, 2023 •

Copy link
Copy Markdown
Author

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` */

@Jersyfi Jersyfi Mar 6, 2023 •

Copy link
Copy Markdown
Author

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)

@Jersyfi Jersyfi changed the title Version path & prefix configuration for plugin content docs feat(content-docs): version path & prefix configuration options Mar 6, 2023

@slorber slorber left a comment •

Copy link
Copy Markdown
Collaborator

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.

@Jersyfi

Jersyfi commented Apr 24, 2023

Copy link
Copy Markdown
Author

Closing the PR as there is no time for further changes.

@Jersyfi Jersyfi closed this Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants