diff --git a/docs/api-pages.md b/docs/api-pages.md index 854e6f631479..7f4821d15ae4 100644 --- a/docs/api-pages.md +++ b/docs/api-pages.md @@ -29,6 +29,33 @@ MyPage.title = 'My Custom Title'; module.exports = MyPage; ``` +## Description for Pages + +By default, the description your page is `tagline` set in [`siteConfig.js`](api-site-config.md). If you want to set a specific description for your custom pages, add a `description` class property on your exported React component. + +Example: + +```js +const React = require('react'); + +class MyPage extends React.Component { + render() { + // ... your rendering code + } +} + +MyPage.description = 'My Custom Description'; + +module.exports = MyPage; +``` + +This will be translated to a description metadata tag on the generated HTML. + +```html + + +``` + ## Page Require Paths Docusaurus provides a few useful React components for users to write their own pages, found in the `CompLibrary` module. This module is provided as part of Docusaurus in `node_modules/docusaurus`, so to access it, pages in the `pages` directory are temporarily copied into `node_modules/docusaurus` when rendering to static HTML. As seen in the example files, this means that a user page at `pages/en/index.js` uses a require path to `'../../core/CompLibrary.js'` to import the provided components. diff --git a/lib/core/Head.js b/lib/core/Head.js index 1d4b52d8dbb4..f8de01d4082c 100644 --- a/lib/core/Head.js +++ b/lib/core/Head.js @@ -36,6 +36,7 @@ class Head extends React.Component { {this.props.title} + diff --git a/lib/server/generate.js b/lib/server/generate.js index 93b510420933..776cabff84f1 100644 --- a/lib/server/generate.js +++ b/lib/server/generate.js @@ -509,6 +509,7 @@ async function execute() { language={language} config={siteConfig} title={ReactComp.title} + description={ReactComp.description} metadata={{id: pageID}}> @@ -528,6 +529,7 @@ async function execute() { title={ReactComp.title} language={language} config={siteConfig} + description={ReactComp.description} metadata={{id: pageID}}> @@ -545,6 +547,7 @@ async function execute() { title={ReactComp.title} language={language} config={siteConfig} + description={ReactComp.description} metadata={{id: pageID}}> diff --git a/lib/server/server.js b/lib/server/server.js index f9f6468b6611..be1c342a46a9 100644 --- a/lib/server/server.js +++ b/lib/server/server.js @@ -449,6 +449,7 @@ function execute(port) { language={language} config={siteConfig} title={ReactComp.title} + description={ReactComp.description} metadata={{id: path.basename(userFile, '.js')}}>