facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
56.68k stars 8.52k forks source link

[v2] unable to use theme-classic without remark-admonitions #2525

Closed phated closed 4 years ago

phated commented 4 years ago

🐛 Bug Report

Due to https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-theme-classic/src/index.js#L56, you are unable to to use the @docusaurus/theme-classic theme without installing the remark-admonitions module. This shouldn't be a hard requirement.

Have you read the Contributing Guidelines on issues?

Yep

To Reproduce

  1. Create a V2 project with the following config
    
    'use strict';

module.exports = { title: 'gulp.js', favicon: 'img/favicon.png', url: 'https://gulpjs.com/', baseUrl: '/', tagline: 'The streaming build system', // Used by the deployment organizationName: 'gulpjs', projectName: 'gulpjs.github.io', // The theme themeConfig: {}, themes: ['@docusaurus/theme-classic'], plugins: [ ['@docusaurus/plugin-content-docs', { path: '../converted-docs' }] ] };


1. Try to run the project
1. See this error message
<img width="918" alt="Screen Shot 2020-04-03 at 6 50 27 PM" src="https://user-images.githubusercontent.com/992373/78416191-07a91d80-75dc-11ea-9aba-8c2a4a4a773b.png">

## Expected behavior

The theme should be usable without external dependencies unless I opt-in.

## Actual Behavior

Doesn't compile and is unusable without installing the `remark-admonitions` module.

## Your Environment

<!-- Include as many relevant details about the environment you experienced the bug in -->

- Docusaurus version used: `^2.0.0-alpha.50`
- Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): 10.15.1
- Operating system and version (desktop or mobile): desktop

## Reproducible Demo

None currently because I'm trying to upgrade the gulp website...
lex111 commented 4 years ago

This is weird, since we included admonitions in core (so there should be no errors with CSS file), how did you remove this module?

phated commented 4 years ago

@lex111 you don't include admonitions in core (see https://github.com/facebook/docusaurus/blob/master/packages/docusaurus/package.json#L34-L88) but include it only in preset-classic (https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-preset-classic/package.json#L19) which I'm not using because I always avoid the preset. I think this theme should check if admonitions is enabled before trying to include that file.

lex111 commented 4 years ago

@phated aah, I get it, we did not consider the case when someone can use the classic theme directly without using the preset (this is not a very popular use case).

phated commented 4 years ago

@lex111 is there a reason that remark-admonitions isn't just providing that lifecycle hook for itself?

yangshun commented 4 years ago

We should shift 'remark-admonitions/styles/infima.css' out of packages/docusaurus-theme-classic/src/index.js into the preset but unfortunately presets don't allow lifecycle hooks at the moment. We might need to change that or create a new API to modify themes within presets. The dependency is a bit tangled up at the moment :/

lex111 commented 4 years ago

@phated I see that the Gulp website is already using the latest version of D2, which is awesome! I hope you were not disappointed with the new version 😜

Regarding this issue, why don't you use preset-classic? Even if you do not need a blog, this should not bring overhead.

phated commented 4 years ago

Yeah, we pushed through any issues because I needed to get it released before a podcast appearance this week. Docusaurus has been amazing, as always!

I'm generally against presets for most tools I use because I end up needing to change a lot of things. For example, I see a world where the gulp team creates their own theme (we've done medium customization already and need more), so I wouldn't want to rip out the preset at that time.

I also think by understanding how the preset is working and reimplementing it myself, I can see things that aren't needed and find issues like this. I have more feedback on the plugin architecture, but I currently don't have the time to write up my thoughts 🙁

lex111 commented 4 years ago

@phated we really love the feedback from our users, thank you for that. We welcome any feedback, because we are still in the alpha stage.

I tend to include admonitions in every plugin (both for docs and blogs), instead of doing this in a preset. I think it was a predictable behavior.

BTW consider adding your project to our showcase at https://v2.docusaurus.io/showcase 😇