Add a scroll to top button siteConfig option (#723)

This commit is contained in:
Lespagnol Rémy 2018-06-06 21:34:32 +02:00 committed by Joel Marcey
parent a43cc597f8
commit aee255219b
4 changed files with 40 additions and 0 deletions

View file

@ -149,6 +149,33 @@ class Head extends React.Component {
);
})}
{this.props.config.scrollToTop && (
<script
src={
'https://unpkg.com/vanilla-back-to-top@7.1.14/dist/vanilla-back-to-top.min.js'
}
/>
)}
{this.props.config.scrollToTop && (
<script
dangerouslySetInnerHTML={{
__html: `
document.addEventListener("DOMContentLoaded", function(){
addBackToTop(
${JSON.stringify(
Object.assign(
{},
{zIndex: 100},
this.props.config.scrollToTopOptions
)
)}
)
});
`,
}}
/>
)}
{/* Site defined code. Keep these at the end to avoid overriding. */}
<link
rel="stylesheet"