mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
Add documentation for setting title of custom pages (#712)
* add customtitle for page doc * Update api-pages.md * Update api-pages.md
This commit is contained in:
parent
72f4f36939
commit
fa20c93d5c
1 changed files with 20 additions and 0 deletions
|
@ -9,6 +9,26 @@ Docusaurus provides support for writing pages as React components inside the `we
|
||||||
|
|
||||||
Any `.js` files in `website/pages` will be rendered to static html using the path of the file after "pages". Files in `website/pages/en` will also get copied out into `pages` and will OVERRIDE any files of the same name in `pages`. For example, the page for the `website/pages/en/help.js` file will be found at the url `${baseUrl}en/help.js` as well as the url `${baseUrl}help.js`, where `${baseUrl}` is the `baseUrl` field set in your [siteConfig.js file](api-site-config.md).
|
Any `.js` files in `website/pages` will be rendered to static html using the path of the file after "pages". Files in `website/pages/en` will also get copied out into `pages` and will OVERRIDE any files of the same name in `pages`. For example, the page for the `website/pages/en/help.js` file will be found at the url `${baseUrl}en/help.js` as well as the url `${baseUrl}help.js`, where `${baseUrl}` is the `baseUrl` field set in your [siteConfig.js file](api-site-config.md).
|
||||||
|
|
||||||
|
## Titles for Pages
|
||||||
|
|
||||||
|
By default, the title of your page is `<title> • <tagline>` where `title` and `tagline` fields are set in [`siteConfig.js`](api-site-config.md). You can exclude the tagline in the title by setting `disableTitleTagline` to `true`. If you want to set a specific title for your custom pages, add a `title` class property on your exported React component.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const React = require('react');
|
||||||
|
|
||||||
|
class MyPage extends React.Component {
|
||||||
|
render() {
|
||||||
|
// ... your rendering code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MyPage.title = 'My Custom Title';
|
||||||
|
|
||||||
|
module.exports = MyPage;
|
||||||
|
```
|
||||||
|
|
||||||
## Page Require Paths
|
## 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` folder 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.
|
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` folder 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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue