mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-27 15:07:53 +02:00
feat(v2): rewrite docs loading strategy (#1092)
* feat(v2): rewrite docs loading strategy * Prettify * Lint * Allow resolving from library root * minor changes, refactor * copyright header
This commit is contained in:
parent
c9243e8922
commit
13a21b2374
36 changed files with 520 additions and 327 deletions
|
@ -5,49 +5,56 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React, {useContext} from 'react';
|
||||
import {Link} from 'react-router-dom';
|
||||
|
||||
import DocusaurusContext from '@docusaurus/context';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
|
||||
export default class DocsPaginator extends React.Component {
|
||||
render() {
|
||||
const {docsMetadatas, metadata} = this.props;
|
||||
return (
|
||||
<div className={styles.paginatorContainer}>
|
||||
<div>
|
||||
{metadata.previous &&
|
||||
docsMetadatas[metadata.previous] && (
|
||||
<Link
|
||||
className={styles.paginatorLink}
|
||||
to={docsMetadatas[metadata.previous].permalink}>
|
||||
<svg className={styles.arrow} viewBox="0 0 24 24">
|
||||
<g>
|
||||
<line x1="19" y1="12" x2="5" y2="12" />
|
||||
<polyline points="12 19 5 12 12 5" />
|
||||
</g>
|
||||
</svg>{' '}
|
||||
<span className={styles.label}>{metadata.previous_title}</span>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.paginatorRightContainer}>
|
||||
{metadata.next &&
|
||||
docsMetadatas[metadata.next] && (
|
||||
<Link
|
||||
className={styles.paginatorLink}
|
||||
to={docsMetadatas[metadata.next].permalink}>
|
||||
<span className={styles.label}>{metadata.next_title}</span>{' '}
|
||||
<svg className={styles.arrow} viewBox="0 0 24 24">
|
||||
<g>
|
||||
<line x1="5" y1="12" x2="19" y2="12" />
|
||||
<polyline points="12 5 19 12 12 19" />
|
||||
</g>
|
||||
</svg>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
function DocsPaginator() {
|
||||
const context = useContext(DocusaurusContext);
|
||||
const {docsMetadatas, metadata} = context;
|
||||
if (!metadata) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.paginatorContainer}>
|
||||
<div>
|
||||
{metadata.previous &&
|
||||
docsMetadatas[metadata.previous] && (
|
||||
<Link
|
||||
className={styles.paginatorLink}
|
||||
to={docsMetadatas[metadata.previous].permalink}>
|
||||
<svg className={styles.arrow} viewBox="0 0 24 24">
|
||||
<g>
|
||||
<line x1="19" y1="12" x2="5" y2="12" />
|
||||
<polyline points="12 19 5 12 12 5" />
|
||||
</g>
|
||||
</svg>{' '}
|
||||
<span className={styles.label}>{metadata.previous_title}</span>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.paginatorRightContainer}>
|
||||
{metadata.next &&
|
||||
docsMetadatas[metadata.next] && (
|
||||
<Link
|
||||
className={styles.paginatorLink}
|
||||
to={docsMetadatas[metadata.next].permalink}>
|
||||
<span className={styles.label}>{metadata.next_title}</span>{' '}
|
||||
<svg className={styles.arrow} viewBox="0 0 24 24">
|
||||
<g>
|
||||
<line x1="5" y1="12" x2="19" y2="12" />
|
||||
<polyline points="12 5 19 12 12 19" />
|
||||
</g>
|
||||
</svg>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default DocsPaginator;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue