mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-15 09:12:24 +02:00
fix(v2): wrong head meta and title (#1354)
This commit is contained in:
parent
5872e2dd91
commit
415d2b33d1
6 changed files with 23 additions and 16 deletions
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Helmet from 'react-helmet';
|
import {Helmet} from 'react-helmet';
|
||||||
|
|
||||||
function Head(props) {
|
function Head(props) {
|
||||||
return <Helmet {...props} />;
|
return <Helmet {...props} />;
|
||||||
|
|
|
@ -9,7 +9,7 @@ import ejs from 'ejs';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {StaticRouter} from 'react-router-dom';
|
import {StaticRouter} from 'react-router-dom';
|
||||||
import ReactDOMServer from 'react-dom/server';
|
import ReactDOMServer from 'react-dom/server';
|
||||||
import Helmet from 'react-helmet';
|
import {Helmet} from 'react-helmet';
|
||||||
import {getBundles} from 'react-loadable-ssr-addon';
|
import {getBundles} from 'react-loadable-ssr-addon';
|
||||||
import Loadable from 'react-loadable';
|
import Loadable from 'react-loadable';
|
||||||
|
|
||||||
|
|
|
@ -19,19 +19,14 @@ import DocusaurusContext from '@docusaurus/context';
|
||||||
import styles from './styles.module.css';
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
function Doc(props) {
|
function Doc(props) {
|
||||||
const {metadata = {}, siteConfig = {}} = useContext(DocusaurusContext);
|
const {siteConfig = {}} = useContext(DocusaurusContext);
|
||||||
const {route} = props;
|
const {route} = props;
|
||||||
const {language, version} = metadata;
|
|
||||||
const {baseUrl, favicon} = siteConfig;
|
const {baseUrl, favicon} = siteConfig;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<Head>
|
<Head>
|
||||||
<title>{(metadata && metadata.title) || siteConfig.title}</title>
|
<title>{siteConfig.title}</title>
|
||||||
{favicon && <link rel="shortcut icon" href={baseUrl + favicon} />}
|
{favicon && <link rel="shortcut icon" href={baseUrl + favicon} />}
|
||||||
{language && <html lang={language} />}
|
|
||||||
{language && <meta name="docsearch:language" content={language} />}
|
|
||||||
{version && <meta name="docsearch:version" content={version} />}
|
|
||||||
</Head>
|
</Head>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
<div className={styles.mainContainer}>
|
<div className={styles.mainContainer}>
|
||||||
|
|
|
@ -9,20 +9,27 @@ import React, {useContext, useEffect} from 'react';
|
||||||
|
|
||||||
import DocsPaginator from '@theme/DocsPaginator'; // eslint-disable-line
|
import DocsPaginator from '@theme/DocsPaginator'; // eslint-disable-line
|
||||||
import DocusaurusContext from '@docusaurus/context';
|
import DocusaurusContext from '@docusaurus/context';
|
||||||
|
import Head from '@docusaurus/Head';
|
||||||
|
|
||||||
import styles from './styles.module.css';
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
function DocBody(props) {
|
function DocBody(props) {
|
||||||
const {metadata, modules} = props;
|
const {metadata, modules} = props;
|
||||||
|
const {language, version} = metadata;
|
||||||
const context = useContext(DocusaurusContext);
|
const context = useContext(DocusaurusContext);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
context.setContext({metadata});
|
context.setContext({metadata});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const DocContents = modules[0];
|
const DocContents = modules[0];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.docBody}>
|
<div className={styles.docBody}>
|
||||||
|
<Head>
|
||||||
|
{metadata && metadata.title && <title>{metadata.title}</title>}
|
||||||
|
{language && <html lang={language} />}
|
||||||
|
{language && <meta name="docsearch:language" content={language} />}
|
||||||
|
{version && <meta name="docsearch:version" content={version} />}
|
||||||
|
</Head>
|
||||||
<div className="container margin-bottom-xl">
|
<div className="container margin-bottom-xl">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col col-8 col-offset-2">
|
<div className="col col-8 col-offset-2">
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
"mini-css-extract-plugin": "^0.4.1",
|
"mini-css-extract-plugin": "^0.4.1",
|
||||||
"portfinder": "^1.0.13",
|
"portfinder": "^1.0.13",
|
||||||
"react-dev-utils": "^8.0.0",
|
"react-dev-utils": "^8.0.0",
|
||||||
"react-helmet": "^5.2.0",
|
"react-helmet": "^6.0.0-beta",
|
||||||
"react-hot-loader": "^4.8.2",
|
"react-hot-loader": "^4.8.2",
|
||||||
"react-listener-provider": "^0.2.0",
|
"react-listener-provider": "^0.2.0",
|
||||||
"react-loadable": "^5.5.0",
|
"react-loadable": "^5.5.0",
|
||||||
|
|
15
yarn.lock
15
yarn.lock
|
@ -10874,14 +10874,19 @@ react-error-overlay@^5.1.4:
|
||||||
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-5.1.4.tgz#88dfb88857c18ceb3b9f95076f850d7121776991"
|
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-5.1.4.tgz#88dfb88857c18ceb3b9f95076f850d7121776991"
|
||||||
integrity sha512-fp+U98OMZcnduQ+NSEiQa4s/XMsbp+5KlydmkbESOw4P69iWZ68ZMFM5a2BuE0FgqPBKApJyRuYHR95jM8lAmg==
|
integrity sha512-fp+U98OMZcnduQ+NSEiQa4s/XMsbp+5KlydmkbESOw4P69iWZ68ZMFM5a2BuE0FgqPBKApJyRuYHR95jM8lAmg==
|
||||||
|
|
||||||
react-helmet@^5.2.0:
|
react-fast-compare@^2.0.2:
|
||||||
version "5.2.0"
|
version "2.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-5.2.0.tgz#a81811df21313a6d55c5f058c4aeba5d6f3d97a7"
|
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-2.0.4.tgz#e84b4d455b0fec113e0402c329352715196f81f9"
|
||||||
integrity sha1-qBgR3yExOm1VxfBYxK66XW89l6c=
|
integrity sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw==
|
||||||
|
|
||||||
|
react-helmet@^6.0.0-beta:
|
||||||
|
version "6.0.0-beta"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-6.0.0-beta.tgz#1f2ac04521951486e4fce3296d0c88aae8cabd5c"
|
||||||
|
integrity sha512-GnNWsokebTe7fe8MH2I/a2dl4THYWhthLBoMaQSRYqW5XbPo881WAJGi+lqRBjyOFryW6zpQluEkBy70zh+h9w==
|
||||||
dependencies:
|
dependencies:
|
||||||
deep-equal "^1.0.1"
|
|
||||||
object-assign "^4.1.1"
|
object-assign "^4.1.1"
|
||||||
prop-types "^15.5.4"
|
prop-types "^15.5.4"
|
||||||
|
react-fast-compare "^2.0.2"
|
||||||
react-side-effect "^1.1.0"
|
react-side-effect "^1.1.0"
|
||||||
|
|
||||||
react-hot-loader@^4.8.2:
|
react-hot-loader@^4.8.2:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue