Enable passing attributes to scripts and links (#937)

This commit is contained in:
Hilu luke 2018-09-04 06:46:55 +08:00 committed by Yangshun Tay
parent 2cbfeffd81
commit 969399c6c5
2 changed files with 32 additions and 10 deletions

View file

@ -137,13 +137,23 @@ class Head extends React.Component {
{/* External resources */}
{this.props.config.stylesheets &&
this.props.config.stylesheets.map(source => (
<link rel="stylesheet" key={source} href={source} />
))}
this.props.config.stylesheets.map(
source =>
source.href ? (
<link rel="stylesheet" key={source.href} {...source} />
) : (
<link rel="stylesheet" key={source} href={source} />
)
)}
{this.props.config.scripts &&
this.props.config.scripts.map(source => (
<script type="text/javascript" key={source} src={source} />
))}
this.props.config.scripts.map(
source =>
source.src ? (
<script type="text/javascript" key={source.src} {...source} />
) : (
<script type="text/javascript" src={source} key={source} />
)
)}
{this.props.config.scrollToTop && (
<script src="https://unpkg.com/vanilla-back-to-top@7.1.14/dist/vanilla-back-to-top.min.js" />