Allow GridBlock images to be clickable links

This commit is contained in:
Frank Li 2017-07-21 13:57:37 -07:00
parent b359a2500d
commit f72144e988
2 changed files with 22 additions and 10 deletions

View file

@ -29,11 +29,11 @@ class GridBlock extends React.Component {
const topLeftImage = const topLeftImage =
(block.imageAlign === "top" || block.imageAlign === "left") && (block.imageAlign === "top" || block.imageAlign === "left") &&
this.renderBlockImage(block.image); this.renderBlockImage(block.image, block.imageLink);
const bottomRightImage = const bottomRightImage =
(block.imageAlign === "bottom" || block.imageAlign === "right") && (block.imageAlign === "bottom" || block.imageAlign === "right") &&
this.renderBlockImage(block.image); this.renderBlockImage(block.image, block.imageLink);
return ( return (
<div className={blockClasses} key={block.title}> <div className={blockClasses} key={block.title}>
@ -49,13 +49,23 @@ class GridBlock extends React.Component {
); );
} }
renderBlockImage(image) { renderBlockImage(image, imageLink) {
if (image) { if (image) {
if (imageLink) {
return (
<div className="blockImage">
<a href={imageLink}>
<img src={image} />
</a>
</div>
);
} else {
return ( return (
<div className="blockImage"> <div className="blockImage">
<img src={image} /> <img src={image} />
</div> </div>
); );
}
} else { } else {
return null; return null;
} }
@ -65,7 +75,9 @@ class GridBlock extends React.Component {
if (title) { if (title) {
return ( return (
<h2> <h2>
<Marked>{title}</Marked> <Marked>
{title}
</Marked>
</h2> </h2>
); );
} else { } else {

View file

@ -21,7 +21,7 @@
"shelljs": "^0.7.8" "shelljs": "^0.7.8"
}, },
"name": "docusaurus", "name": "docusaurus",
"version": "1.0.0-alpha.26", "version": "1.0.0-alpha.27",
"bin": { "bin": {
"docusaurus-start": "./lib/start-server.js", "docusaurus-start": "./lib/start-server.js",
"docusaurus-build": "./lib/build-files.js", "docusaurus-build": "./lib/build-files.js",