From cd47d8a81534c70aa1bcc08bab66220ec92f30f9 Mon Sep 17 00:00:00 2001 From: Steven Hansel Date: Thu, 15 Apr 2021 23:36:40 +0700 Subject: [PATCH] feat(v2): add unique page/wrapper className to each theme pages (#4511) * chore: add theme classnames for blog pages * fix: component syntax error in blog pages * style: fix camelcase issue with theme class names * chore: add theme classnames for doc page and mdx page * chore: make wrapper classnames in blog and doc page into constants * chore: add main wrapper theme class name for layout component * fix: change wrong theme classnames and improve naming * chore: add wrapper theme class name for mdx page * docs: add docs for theme class names * docs: use raw-loader to import documentation and add some comments * docs: provide more detail to comment * chore: rename ThemeClassname.ts to ThemeClassName.ts Co-authored-by: Lisa Chandra <52909743+lisa761@users.noreply.github.com> Co-authored-by: Javid --- .../src/theme/BlogListPage/index.tsx | 4 +++- .../src/theme/BlogPostPage/index.tsx | 4 +++- .../src/theme/BlogTagsListPage/index.tsx | 4 +++- .../src/theme/BlogTagsPostsPage/index.tsx | 5 ++-- .../src/theme/DocPage/index.tsx | 5 ++-- .../src/theme/Layout/index.tsx | 12 ++++++++-- .../src/theme/MDXPage/index.tsx | 4 +++- .../docusaurus-theme-classic/src/types.d.ts | 1 + packages/docusaurus-theme-common/src/index.ts | 2 ++ .../src/utils/ThemeClassNames.ts | 24 +++++++++++++++++++ website/docs/styling-layout.md | 12 ++++++++++ 11 files changed, 67 insertions(+), 10 deletions(-) create mode 100644 packages/docusaurus-theme-common/src/utils/ThemeClassNames.ts diff --git a/packages/docusaurus-theme-classic/src/theme/BlogListPage/index.tsx b/packages/docusaurus-theme-classic/src/theme/BlogListPage/index.tsx index 76bcedd218..393602c90b 100644 --- a/packages/docusaurus-theme-classic/src/theme/BlogListPage/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/BlogListPage/index.tsx @@ -13,6 +13,7 @@ import BlogPostItem from '@theme/BlogPostItem'; import BlogListPaginator from '@theme/BlogListPaginator'; import type {Props} from '@theme/BlogListPage'; import BlogSidebar from '@theme/BlogSidebar'; +import {ThemeClassNames} from '@docusaurus/theme-common'; function BlogListPage(props: Props): JSX.Element { const {metadata, items, sidebar} = props; @@ -26,7 +27,8 @@ function BlogListPage(props: Props): JSX.Element { + wrapperClassName={ThemeClassNames.wrapper.blogPages} + pageClassName={ThemeClassNames.page.blogPostPage}> {BlogPostContents && (
diff --git a/packages/docusaurus-theme-classic/src/theme/BlogTagsListPage/index.tsx b/packages/docusaurus-theme-classic/src/theme/BlogTagsListPage/index.tsx index 8ce584d975..2bdb11905b 100644 --- a/packages/docusaurus-theme-classic/src/theme/BlogTagsListPage/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/BlogTagsListPage/index.tsx @@ -12,6 +12,7 @@ import Link from '@docusaurus/Link'; import type {Props} from '@theme/BlogTagsListPage'; import BlogSidebar from '@theme/BlogSidebar'; import Translate from '@docusaurus/Translate'; +import {ThemeClassNames} from '@docusaurus/theme-common'; function getCategoryOfTag(tag: string) { // tag's category should be customizable @@ -54,7 +55,8 @@ function BlogTagsListPage(props: Props): JSX.Element { -
{children}
+
+ {children} +
{!noFooter &&