mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
feat: add next/prev button for docs according to sidebar
This commit is contained in:
parent
11b0d15238
commit
318ea5fbb5
3 changed files with 42 additions and 5 deletions
|
@ -144,14 +144,14 @@ module.exports = async function processMetadata(
|
|||
metadata.id = `version-${version}-${metadata.id}`;
|
||||
}
|
||||
|
||||
/* save localized id before adding language on it*/
|
||||
metadata.localized_id = metadata.id;
|
||||
|
||||
/* if language */
|
||||
if (language) {
|
||||
metadata.id = `${language}-${metadata.id}`;
|
||||
}
|
||||
|
||||
/* localize id */
|
||||
metadata.localized_id = metadata.id;
|
||||
|
||||
/* Determine order */
|
||||
const id = metadata.localized_id;
|
||||
if (order[id]) {
|
||||
|
|
|
@ -6,13 +6,37 @@ import Layout from '@theme/Layout'; // eslint-disable-line
|
|||
|
||||
export default class Docs extends React.Component {
|
||||
render() {
|
||||
const {route, siteConfig, metadata} = this.props;
|
||||
const {route, siteConfig, docsMetadata, metadata} = this.props;
|
||||
return (
|
||||
<Layout {...this.props}>
|
||||
<Helmet>
|
||||
<title>{(metadata && metadata.title) || siteConfig.title}</title>
|
||||
</Helmet>
|
||||
<div className={styles.mainContainer}>{this.props.children}</div>
|
||||
<div className="docs-prevnext">
|
||||
{metadata.previous &&
|
||||
docsMetadata[metadata.previous] && (
|
||||
<a
|
||||
className="docs-prev button"
|
||||
href={docsMetadata[metadata.previous].permalink}>
|
||||
<span className="arrow-prev">← </span>
|
||||
<span>{metadata.previous_title}</span>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
<div className="docs-prevnext">
|
||||
{metadata.next &&
|
||||
docsMetadata[metadata.next] && (
|
||||
<a
|
||||
className="docs-prev button"
|
||||
href={docsMetadata[metadata.next].permalink}>
|
||||
<span>{metadata.next_title}</span>
|
||||
<span className="arrow-prev">→ </span>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.mainContainer}>
|
||||
{this.props.children}
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
|
13
website/sidebars.json
Normal file
13
website/sidebars.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"docs": {
|
||||
"Foo": [
|
||||
"foo/bar",
|
||||
"foo/baz"
|
||||
],
|
||||
"Endi": [
|
||||
"docusaurus",
|
||||
"highlight",
|
||||
"hello"
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue