diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index 0c6633ed3551..9ef37bf73df4 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -9,6 +9,7 @@ const React = require('react'); const Container = require('./Container.js'); const Doc = require('./Doc.js'); const DocsSidebar = require('./DocsSidebar.js'); +const OnPageNav = require('./nav/OnPageNav.js'); const Site = require('./Site.js'); const translation = require('../server/translation.js'); @@ -25,7 +26,7 @@ class DocsLayout extends React.Component { return ( + {this.props.config.onPageNav == 'separate' && ( + + )} ); diff --git a/lib/core/Site.js b/lib/core/Site.js index 6ac9a235b286..6506e0ed74a5 100644 --- a/lib/core/Site.js +++ b/lib/core/Site.js @@ -11,6 +11,7 @@ const HeaderNav = require('./nav/HeaderNav.js'); const Head = require('./Head.js'); const Footer = require(process.cwd() + '/core/Footer.js'); const translation = require('../server/translation.js'); +const classNames = require('classnames'); const CWD = process.cwd(); @@ -63,7 +64,11 @@ class Site extends React.Component { title={title} url={url} /> - + {text}; + +const Headings = ({headings}) => { + if (!headings.length) return null; + return ( + + ); +}; + +class OnPageNav extends React.Component { + render() { + const customTags = siteConfig.onPageNavHeadings; + const headings = customTags + ? getTOC(this.props.rawContent, customTags.topLevel, customTags.sub) + : getTOC(this.props.rawContent); + + return ; + } +} + +module.exports = OnPageNav; diff --git a/lib/static/css/main.css b/lib/static/css/main.css index 5bc67e47c375..3dd560e23300 100644 --- a/lib/static/css/main.css +++ b/lib/static/css/main.css @@ -1494,6 +1494,73 @@ nav.toc .toggleNav .navBreadcrumb h2 { padding: 0 10px; } } + +.onPageNav { + display: none; +} +.onPageNav::-webkit-scrollbar { + display: none; +} + +@supports(position: sticky) { + @media only screen and (min-width: 1024px) { + .separateOnPageNav.doc .wrapper, + .separateOnPageNav .headerWrapper.wrapper { + max-width: 1400px; + } + + .doc.separateOnPageNav .docsNavContainer { + flex: 0 0 240px; + margin: 40px 0 0; + } + + .doc.separateOnPageNav nav.toc:last-child { + padding-bottom: 0; + width: auto; + } + + .doc.separateOnPageNav.sideNavVisible .navPusher .mainContainer { + max-width: 100%; + flex: 1 auto; + padding: 0 40px 50px; + min-width: 0; + } + + .onPageNav { + display: block; + position: -webkit-sticky; + position: sticky; + top: 110px; + flex: 0 0 240px; + overflow-y: auto; + max-height: calc(100vh - 110px); + } + + .onPageNav > ul { + border-left: 1px solid #e0e0e0; + padding: 10px 0 2px 15px; + } + + .onPageNav a { + color: #717171; + } + + .onPageNav ul li { + font-size: 12px; + line-height: 14px; + padding-bottom: 12px; + } + + .onPageNav ul ul { + padding: 8px 0 0 20px; + } + + .onPageNav ul ul li { + padding-bottom: 8px; + } + } +} + table { background: #F8F8F8; border: 1px solid #B0B0B0;