mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
Enable sub-directories in docs/ (#705)
This commit is contained in:
parent
49c27b733b
commit
d04b3ca87b
10 changed files with 135 additions and 36 deletions
|
@ -12,9 +12,20 @@ const DocsSidebar = require('./DocsSidebar.js');
|
|||
const OnPageNav = require('./nav/OnPageNav.js');
|
||||
const Site = require('./Site.js');
|
||||
const translation = require('../server/translation.js');
|
||||
const path = require('path');
|
||||
|
||||
// component used to generate whole webpage for docs, including sidebar/header/footer
|
||||
class DocsLayout extends React.Component {
|
||||
getRelativeURL = (from, to) => {
|
||||
const extension = this.props.config.cleanUrl ? '' : '.html';
|
||||
return (
|
||||
path
|
||||
.relative(from, to)
|
||||
.replace('\\', '/')
|
||||
.replace(/^\.\.\//, '') + extension
|
||||
);
|
||||
};
|
||||
|
||||
render() {
|
||||
const metadata = this.props.metadata;
|
||||
const content = this.props.children;
|
||||
|
@ -28,7 +39,6 @@ class DocsLayout extends React.Component {
|
|||
this.props.metadata.localized_id
|
||||
] || this.props.metadata.title
|
||||
: this.props.metadata.title;
|
||||
const extension = this.props.config.cleanUrl ? '' : '.html';
|
||||
return (
|
||||
<Site
|
||||
config={this.props.config}
|
||||
|
@ -55,7 +65,10 @@ class DocsLayout extends React.Component {
|
|||
{metadata.previous_id && (
|
||||
<a
|
||||
className="docs-prev button"
|
||||
href={metadata.previous_id + extension}>
|
||||
href={this.getRelativeURL(
|
||||
metadata.localized_id,
|
||||
metadata.previous_id
|
||||
)}>
|
||||
←{' '}
|
||||
{i18n
|
||||
? translation[this.props.metadata.language][
|
||||
|
@ -71,7 +84,10 @@ class DocsLayout extends React.Component {
|
|||
{metadata.next_id && (
|
||||
<a
|
||||
className="docs-next button"
|
||||
href={metadata.next_id + extension}>
|
||||
href={this.getRelativeURL(
|
||||
metadata.localized_id,
|
||||
metadata.next_id
|
||||
)}>
|
||||
{i18n
|
||||
? translation[this.props.metadata.language][
|
||||
'localized-strings'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue