mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
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:
parent
e486d3d1b0
commit
f0d5313d48
20 changed files with 33 additions and 27 deletions
|
@ -338,10 +338,6 @@ module.exports = function(context, opts) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getThemePath() {
|
|
||||||
return path.resolve(__dirname, './theme');
|
|
||||||
},
|
|
||||||
|
|
||||||
configureWebpack(config, isServer, {getBabelLoader, getCacheLoader}) {
|
configureWebpack(config, isServer, {getBabelLoader, getCacheLoader}) {
|
||||||
const {rehypePlugins, remarkPlugins} = options;
|
const {rehypePlugins, remarkPlugins} = options;
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -17,10 +17,8 @@
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@docusaurus/core": "^2.0.0",
|
"@docusaurus/core": "^2.0.0",
|
||||||
"classnames": "^2.2.6",
|
|
||||||
"react": "^16.8.4",
|
"react": "^16.8.4",
|
||||||
"react-dom": "^16.8.4",
|
"react-dom": "^16.8.4"
|
||||||
"react-router-config": "^5.0.1"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
|
|
|
@ -155,10 +155,6 @@ module.exports = function(context, opts) {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getThemePath() {
|
|
||||||
return path.resolve(__dirname, './theme');
|
|
||||||
},
|
|
||||||
|
|
||||||
configureWebpack(config, isServer, {getBabelLoader, getCacheLoader}) {
|
configureWebpack(config, isServer, {getBabelLoader, getCacheLoader}) {
|
||||||
const {rehypePlugins, remarkPlugins} = options;
|
const {rehypePlugins, remarkPlugins} = options;
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import Layout from '@theme/Layout'; // eslint-disable-line
|
import Layout from '@theme/Layout';
|
||||||
import BlogPostItem from '@theme/BlogPostItem';
|
import BlogPostItem from '@theme/BlogPostItem';
|
||||||
import BlogListPaginator from '@theme/BlogListPaginator';
|
import BlogListPaginator from '@theme/BlogListPaginator';
|
||||||
|
|
|
@ -6,7 +6,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import {MDXProvider} from '@mdx-js/react';
|
||||||
|
|
||||||
import Link from '@docusaurus/Link';
|
import Link from '@docusaurus/Link';
|
||||||
|
import MDXComponents from '@theme/MDXComponents';
|
||||||
|
|
||||||
function BlogPostItem(props) {
|
function BlogPostItem(props) {
|
||||||
const {children, frontMatter, metadata, truncated} = props;
|
const {children, frontMatter, metadata, truncated} = props;
|
||||||
|
@ -80,7 +83,9 @@ function BlogPostItem(props) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{renderPostHeader()}
|
{renderPostHeader()}
|
||||||
<article className="markdown">{children}</article>
|
<article className="markdown">
|
||||||
|
<MDXProvider components={MDXComponents}>{children}</MDXProvider>
|
||||||
|
</article>
|
||||||
<div className="row margin-vert--lg">
|
<div className="row margin-vert--lg">
|
||||||
<div className="col">
|
<div className="col">
|
||||||
{tags.length > 0 && (
|
{tags.length > 0 && (
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import Layout from '@theme/Layout'; // eslint-disable-line
|
import Layout from '@theme/Layout';
|
||||||
import BlogPostItem from '@theme/BlogPostItem';
|
import BlogPostItem from '@theme/BlogPostItem';
|
||||||
import BlogPostPaginator from '@theme/BlogPostPaginator';
|
import BlogPostPaginator from '@theme/BlogPostPaginator';
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import Layout from '@theme/Layout'; // eslint-disable-line
|
import Layout from '@theme/Layout';
|
||||||
import Link from '@docusaurus/Link';
|
import Link from '@docusaurus/Link';
|
||||||
|
|
||||||
const CHARS_IN_ALPHABET = 26;
|
const CHARS_IN_ALPHABET = 26;
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import Layout from '@theme/Layout'; // eslint-disable-line
|
import Layout from '@theme/Layout';
|
||||||
import BlogPostItem from '@theme/BlogPostItem';
|
import BlogPostItem from '@theme/BlogPostItem';
|
||||||
import Link from '@docusaurus/Link';
|
import Link from '@docusaurus/Link';
|
||||||
|
|
|
@ -6,11 +6,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {renderRoutes} from 'react-router-config';
|
import {MDXProvider} from '@mdx-js/react';
|
||||||
|
|
||||||
import Layout from '@theme/Layout'; // eslint-disable-line
|
|
||||||
|
|
||||||
|
import renderRoutes from '@docusaurus/renderRoutes';
|
||||||
|
import Layout from '@theme/Layout';
|
||||||
import DocSidebar from '@theme/DocSidebar';
|
import DocSidebar from '@theme/DocSidebar';
|
||||||
|
import MDXComponents from '@theme/MDXComponents';
|
||||||
|
|
||||||
function DocPage(props) {
|
function DocPage(props) {
|
||||||
const {route, docsMetadata, location} = props;
|
const {route, docsMetadata, location} = props;
|
||||||
|
@ -29,7 +30,9 @@ function DocPage(props) {
|
||||||
<DocSidebar docsMetadata={docsMetadata} sidebar={sidebar} />
|
<DocSidebar docsMetadata={docsMetadata} sidebar={sidebar} />
|
||||||
</div>
|
</div>
|
||||||
<main className="col">
|
<main className="col">
|
||||||
{renderRoutes(route.routes, {docsMetadata})}
|
<MDXProvider components={MDXComponents}>
|
||||||
|
{renderRoutes(route.routes, {docsMetadata})}
|
||||||
|
</MDXProvider>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -6,13 +6,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {MDXProvider} from '@mdx-js/react';
|
|
||||||
import Head from '@docusaurus/Head';
|
import Head from '@docusaurus/Head';
|
||||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
import withBaseUrl from '@docusaurus/withBaseUrl';
|
import withBaseUrl from '@docusaurus/withBaseUrl';
|
||||||
import Navbar from '@theme/Navbar';
|
import Navbar from '@theme/Navbar';
|
||||||
import Footer from '@theme/Footer';
|
import Footer from '@theme/Footer';
|
||||||
import MDXComponents from '@theme/MDXComponents';
|
|
||||||
|
|
||||||
import './styles.css';
|
import './styles.css';
|
||||||
|
|
||||||
|
@ -32,7 +30,7 @@ function Layout(props) {
|
||||||
)}
|
)}
|
||||||
</Head>
|
</Head>
|
||||||
<Navbar />
|
<Navbar />
|
||||||
<MDXProvider components={MDXComponents}>{children}</MDXProvider>
|
{children}
|
||||||
{!noFooter && <Footer />}
|
{!noFooter && <Footer />}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,11 +6,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {renderRoutes} from 'react-router-config';
|
|
||||||
|
|
||||||
import routes from '@generated/routes';
|
import routes from '@generated/routes';
|
||||||
import siteConfig from '@generated/docusaurus.config';
|
import siteConfig from '@generated/docusaurus.config';
|
||||||
|
import renderRoutes from '@docusaurus/renderRoutes';
|
||||||
import DocusaurusContext from '@docusaurus/context';
|
import DocusaurusContext from '@docusaurus/context';
|
||||||
import PendingNavigation from './PendingNavigation';
|
import PendingNavigation from './PendingNavigation';
|
||||||
|
|
||||||
|
|
10
packages/docusaurus/src/client/exports/renderRoutes.js
Normal file
10
packages/docusaurus/src/client/exports/renderRoutes.js
Normal 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;
|
|
@ -78,8 +78,9 @@ The headers are well-spaced so that the hierarchy is clear.
|
||||||
|
|
||||||
- lists will help you
|
- lists will help you
|
||||||
- present the key points
|
- present the key points
|
||||||
- that you want your users to quickly remember
|
- that you want your users to remember
|
||||||
- and you may nest them - multiple layers
|
- and you may nest them
|
||||||
|
- multiple times
|
||||||
|
|
||||||
</BrowserWindow>
|
</BrowserWindow>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue