-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
Need a quick Docusaurus V2 example of developing a plugin. #1928
Comments
Hi @goodlux what kind of plugins are you trying to write? For plugins that perform a single task that does not participate in the static site's build step, you can take a look at the gtag plugin. If you hope to write a plugin like |
Another simpler example is https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-plugin-ideal-image/src/index.js It tries to modify webpack config. and it provides a theme component. Much much simpler than pages plugin (i think) Help on documentation is appreciated |
Would be nice to have a boilerplate with all the TypeScript tooling setup, such that you can
|
@vjpr you don't need a monorepo setup to handle your own plugins. If they are small and only useful for your site you can use a local plugin. https://v2.docusaurus.io/docs/using-plugins/#installing-a-plugin I think this is good enough for most sites, not sure we want to maintain a monorepo setup boilerplate. Maybe the init boilerplate could include a local plugin. About TS, not all D2 users are frontend developers, so it's probably not a good idea to include anything related to TS by default. |
For new users the auto-complete from TypeScript would be useful. |
One thing that we could do is bootstrap new projects with an empty JS plugin with all the lifecycles as noop. For TS users, we could annotate the plugins JS files with JS docs comment? Need to check that, but maybe the IDE's would understand the syntax and provide autocomplete? https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html |
📚 Documentation
Complete noob here, trying to write a simple plugin for Docusarus v2.
Trying to use these docs to reach that end:
https://v2.docusaurus.io/docs/advanced-plugins
I realize this doc is a WIP at this stage, but it is a bit of a mish-mash, and I'm having trouble trying to instantiate and use a local plugin after installing. I've tried everything and now my eyes are bleeding.
Would be really helpful to have a super easy example of a one-function plugin that does something easy like read and write a file, or even print something to the javascript console. I'm happy to write this doc if someone can get me started with a simple code sample.
The sample here appears to be a complete plugin scaffold:
https://v2.docusaurus.io/docs/lifecycle-apis#example
But again, having trouble understanding where this code is actually called in the build process after running :
npm start
Thanks!
Have you read the Contributing Guidelines on issues?
Yes
The text was updated successfully, but these errors were encountered: