-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Support shorthand for themes/plugins/presets configuration #5883
Comments
This would be cool to have. Have you done some field research about how Docusaurus packages look like in the wild? Is |
I took a look. In the NPM, there are 27 packages, and just one is using Although unpopular, it seems to me that |
May I implement it and open a PR? |
@fsmaia I'm personally in favor of this but let's hear from @slorber as well. Three things I'm not sure of though:
|
That's worth doing a POC, see how complex it would be to support and apply to our own config file 👍 I'd rather not introduce too many fallback patterns but rather only a few ones so that the naming convention the community uses is consistent and there's not much possible naming choices if you want shorthand to work |
For sure!
IMHO no, we should encourage developers to move their packages to be adherent to the naming convention, and then this would give the main benefits (raising popularity and discoverability)
The
In a generic way, after the scopes started being widely used, it seems to me that:
I guess this is the rationale behind ESLint shareable config resolvers (and other tools too, if you will I can bring more references in the community), and IMHO it makes a lot of sense. |
To validate the idea and an implementation suggestion, I started a draft PR. As you guys adds suggestions, I'll apply the same behavior for themes and presets |
Have you read the Contributing Guidelines on issues?
Description
When configuring a theme, plugin, or preset, instead of looking up for the NPM package itself, we could have a chain of NPM package resolve attempts, in the respective order/priority:
docusaurus-theme-{theme}
@docusaurus/theme-{theme}
@{theme}/docusaurus-theme
{theme}
The same for plugins and presets.
Example docusaurus configuration:
Package resolve attempts:
docusaurus-theme-classic
@docusaurus/theme-classic
@classic/docusaurus-theme
classic
PS.: it is not clear to me if we should lookup for scoped packages only when the user input begins with
@
, so there are two alternatives:A:
themes: ['@org']
->@org/docusaurus-theme
(resolvers chain, as of the numbered list above: 3)B:
themes: ['org']
->@org/docusaurus-theme
(resolvers chain, as of the numbered list above: 1, 2, 3, 4)Has this been requested on Canny?
https://docusaurus.io/feature-requests/p/shorthand-for-themespluginspresets-configuration
Motivation
Some modern tools are adopting the "shareable config" concept, generally supporting shorthand, so the user may omit the keywords that may be inferred, e.g.
eslint-config-{config}
,eslint-plugin-{plugin}
.This also encourages developers to publish their packages in a canonical way (including
docusaurus-(theme|plugin|preset)
in the name), so a GitHub or NPM search would result in way more packages, therefore increasing their reusability and popularity.Reference:
https://eslint.org/docs/developer-guide/shareable-configs
API design
I guess the API design is pretty straightforward: users may omit the following keywords in their configuration:
docusaurus-theme
docusaurus-plugin
docusaurus-preset
About the implementation itself, we could use ESLint as the baseline:
https://github.com/eslint/eslintrc/blob/main/lib/shared/naming.js#L14
Or thinking in a more ambitious way, we could have a dedicated package/repository to that, just like cosmiconfig, which does the same, but for configuration file names lookup.
Have you tried building it?
No response
Self-service
The text was updated successfully, but these errors were encountered: