facebook / docusaurus

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

Cannot differentiate `BlogListPage` and `BlogPostPage` for styling #4322

Closed roydukkey closed 3 years ago

roydukkey commented 3 years ago

🚀 Feature

Add class names to individuate blog theme components.

Have you read the Contributing Guidelines on issues?

Yes

Motivation

Having a class name to differentiate blog list pages from post pages would allow styling the pages using the global style methodology.

Pitch

Currently, global styling is not possible since there is not variancy between the structures of BlogListPage and BlogPostPage. Adding another class name (e.g. blog-list-page, blog-post-page), alongside the blog-wrapper class name, would allow for global styling.

Furthermore, there doesn't seem to be another way to inject additional class names into these components except to wrap them. I don't feel wrapping the components is a good flow, just to add classes to target for styling, since a global styling methodology often tries to lessen its dependency on structure.

For the docusaurus-theme-classic, these are the proposed changes to the blog components:

slorber commented 3 years ago

Make sense, all docusaurus pages should have a convenient way to target them with custom CSS.

In general, we should have:

Each theme page should rather always have 2 classes, like blog-wrapper blog-list-page

For retrocompatibility we'd rather avoid refactoring existing classes

I'd also like to have all those classnames being migrated to the theme-common package under a constant file like ThemeClassnames.ts, so that it's more explicit that those classnames should remain stable over time or we'd break user's custom CSS

Assigning this task to MLH fellows.

slorber commented 3 years ago

FYI there's also a need to be able to target with CSS a specific doc/version/blog/page: https://github.com/facebook/docusaurus/issues/4280

Ie we probably want a classname like docs-wrapper doc-item-page version-1.0.0 docId?

javidrashid commented 3 years ago

@ShinteiMai to work on this.