Have you read the Contributing Guidelines on issues?
Description
Let me know if I've missed it, but is there any chance we could get documentation for creating a new Docusaurus theme?
I'm trying to figure this out at the moment by reviewing docusaurus-theme-classic, but some actual documentation would be great.
Some information that would be useful to document:
| Topic |
What I think I know |
| Recommended project structure/exports for the theme |
It looks to me that we need: - An
index.jsx with a default export with theme metadata. - Our
package.json must have at least "exports" → "." → "require" === "./src/index.js" so that it can be imported via CJS, which Docusaurus requires when building the website.
|
| What the top-level components are |
For example, ./theme/Navbar/index.jsx seems to be internal for docusaurus-theme-classic, but the actual theme API requires ./theme/Layout/index.jsx, which in docusaurus-theme-classic happens to have the Navbar in it. Knowing what is API vs. implementation detail without having to dive into the code would be wonderful. |
| How to define global CSS for the theme |
Looks like this is through #getClientModules in when exporting theme metadata. |
| In general what other capabilities exist in the theme API |
|
Motivation
I'm exploring making our own theme for svgo.dev.
- When we started, the plan was to work to pretty much just use Markdown, only writing JSX for the landing page. But we've been slowly adding more React code, and overriding components from docusaurus-theme-classic, and will only be doing this more.
- I'm thinking it should be manageable for us to maintain a theme for internal use. (Open Source, but not intended as a stable library). This will make it much easier to do what we want without fussing with which upstream component is doing something, or performing unsafe swizzle operations, etc.
- Reduces concerns between updates of Docusaurus, like import changes or visual changes in the themes.
- Reduce bundles. Not that svgo.dev/Docusaurus is slow, but by writing our own theme I'd expect us to be able to reduce the bundle size since we can significantly reduce the final CSS, implement color themes the way we'd like, remove features we don't need, like the announcements bar, etc.
Self-service
Have you read the Contributing Guidelines on issues?
Description
Let me know if I've missed it, but is there any chance we could get documentation for creating a new Docusaurus theme?
I'm trying to figure this out at the moment by reviewing docusaurus-theme-classic, but some actual documentation would be great.
Some information that would be useful to document:
index.jsxwith a default export with theme metadata.package.jsonmust have at least"exports"→"."→"require"==="./src/index.js"so that it can be imported via CJS, which Docusaurus requires when building the website../theme/Navbar/index.jsxseems to be internal fordocusaurus-theme-classic, but the actual theme API requires./theme/Layout/index.jsx, which indocusaurus-theme-classichappens to have the Navbar in it. Knowing what is API vs. implementation detail without having to dive into the code would be wonderful.#getClientModulesin when exporting theme metadata.Motivation
I'm exploring making our own theme for svgo.dev.
Self-service