refactor(v2): move themes components from docs blog (#1571)

* refactor(v2): move themes from docs blog

* move mdxprovider to docs and blog only
This commit is contained in:
Endi 2019-06-06 16:53:47 +07:00 committed by GitHub
parent e486d3d1b0
commit f0d5313d48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 33 additions and 27 deletions

View file

@ -338,10 +338,6 @@ module.exports = function(context, opts) {
}
},
getThemePath() {
return path.resolve(__dirname, './theme');
},
configureWebpack(config, isServer, {getBabelLoader, getCacheLoader}) {
const {rehypePlugins, remarkPlugins} = options;
return {

View file

@ -17,10 +17,8 @@
},
"peerDependencies": {
"@docusaurus/core": "^2.0.0",
"classnames": "^2.2.6",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-router-config": "^5.0.1"
"react-dom": "^16.8.4"
},
"engines": {
"node": ">=8"

View file

@ -155,10 +155,6 @@ module.exports = function(context, opts) {
});
},
getThemePath() {
return path.resolve(__dirname, './theme');
},
configureWebpack(config, isServer, {getBabelLoader, getCacheLoader}) {
const {rehypePlugins, remarkPlugins} = options;
return {

View file

@ -7,7 +7,7 @@
import React from 'react';
import Layout from '@theme/Layout'; // eslint-disable-line
import Layout from '@theme/Layout';
import BlogPostItem from '@theme/BlogPostItem';
import BlogListPaginator from '@theme/BlogListPaginator';

View file

@ -6,7 +6,10 @@
*/
import React from 'react';
import {MDXProvider} from '@mdx-js/react';
import Link from '@docusaurus/Link';
import MDXComponents from '@theme/MDXComponents';
function BlogPostItem(props) {
const {children, frontMatter, metadata, truncated} = props;
@ -80,7 +83,9 @@ function BlogPostItem(props) {
return (
<div>
{renderPostHeader()}
<article className="markdown">{children}</article>
<article className="markdown">
<MDXProvider components={MDXComponents}>{children}</MDXProvider>
</article>
<div className="row margin-vert--lg">
<div className="col">
{tags.length > 0 && (

View file

@ -7,7 +7,7 @@
import React from 'react';
import Layout from '@theme/Layout'; // eslint-disable-line
import Layout from '@theme/Layout';
import BlogPostItem from '@theme/BlogPostItem';
import BlogPostPaginator from '@theme/BlogPostPaginator';

View file

@ -7,7 +7,7 @@
import React from 'react';
import Layout from '@theme/Layout'; // eslint-disable-line
import Layout from '@theme/Layout';
import Link from '@docusaurus/Link';
const CHARS_IN_ALPHABET = 26;

View file

@ -7,7 +7,7 @@
import React from 'react';
import Layout from '@theme/Layout'; // eslint-disable-line
import Layout from '@theme/Layout';
import BlogPostItem from '@theme/BlogPostItem';
import Link from '@docusaurus/Link';

View file

@ -6,11 +6,12 @@
*/
import React from 'react';
import {renderRoutes} from 'react-router-config';
import Layout from '@theme/Layout'; // eslint-disable-line
import {MDXProvider} from '@mdx-js/react';
import renderRoutes from '@docusaurus/renderRoutes';
import Layout from '@theme/Layout';
import DocSidebar from '@theme/DocSidebar';
import MDXComponents from '@theme/MDXComponents';
function DocPage(props) {
const {route, docsMetadata, location} = props;
@ -29,7 +30,9 @@ function DocPage(props) {
<DocSidebar docsMetadata={docsMetadata} sidebar={sidebar} />
</div>
<main className="col">
{renderRoutes(route.routes, {docsMetadata})}
<MDXProvider components={MDXComponents}>
{renderRoutes(route.routes, {docsMetadata})}
</MDXProvider>
</main>
</div>
</div>

View file

@ -6,13 +6,11 @@
*/
import React from 'react';
import {MDXProvider} from '@mdx-js/react';
import Head from '@docusaurus/Head';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import withBaseUrl from '@docusaurus/withBaseUrl';
import Navbar from '@theme/Navbar';
import Footer from '@theme/Footer';
import MDXComponents from '@theme/MDXComponents';
import './styles.css';
@ -32,7 +30,7 @@ function Layout(props) {
)}
</Head>
<Navbar />
<MDXProvider components={MDXComponents}>{children}</MDXProvider>
{children}
{!noFooter && <Footer />}
</React.Fragment>
);

View file

@ -6,11 +6,10 @@
*/
import React from 'react';
import {renderRoutes} from 'react-router-config';
import routes from '@generated/routes';
import siteConfig from '@generated/docusaurus.config';
import renderRoutes from '@docusaurus/renderRoutes';
import DocusaurusContext from '@docusaurus/context';
import PendingNavigation from './PendingNavigation';

View file

@ -0,0 +1,10 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {renderRoutes} from 'react-router-config';
export default renderRoutes;

View file

@ -78,8 +78,9 @@ The headers are well-spaced so that the hierarchy is clear.
- lists will help you
- present the key points
- that you want your users to quickly remember
- and you may nest them - multiple layers
- that you want your users to remember
- and you may nest them
- multiple times
</BrowserWindow>