mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-25 14:07:50 +02:00
Allow GridBlock images to be clickable links
This commit is contained in:
parent
b359a2500d
commit
f72144e988
2 changed files with 22 additions and 10 deletions
|
@ -29,11 +29,11 @@ class GridBlock extends React.Component {
|
|||
|
||||
const topLeftImage =
|
||||
(block.imageAlign === "top" || block.imageAlign === "left") &&
|
||||
this.renderBlockImage(block.image);
|
||||
this.renderBlockImage(block.image, block.imageLink);
|
||||
|
||||
const bottomRightImage =
|
||||
(block.imageAlign === "bottom" || block.imageAlign === "right") &&
|
||||
this.renderBlockImage(block.image);
|
||||
this.renderBlockImage(block.image, block.imageLink);
|
||||
|
||||
return (
|
||||
<div className={blockClasses} key={block.title}>
|
||||
|
@ -49,13 +49,23 @@ class GridBlock extends React.Component {
|
|||
);
|
||||
}
|
||||
|
||||
renderBlockImage(image) {
|
||||
renderBlockImage(image, imageLink) {
|
||||
if (image) {
|
||||
return (
|
||||
<div className="blockImage">
|
||||
<img src={image} />
|
||||
</div>
|
||||
);
|
||||
if (imageLink) {
|
||||
return (
|
||||
<div className="blockImage">
|
||||
<a href={imageLink}>
|
||||
<img src={image} />
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div className="blockImage">
|
||||
<img src={image} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -65,7 +75,9 @@ class GridBlock extends React.Component {
|
|||
if (title) {
|
||||
return (
|
||||
<h2>
|
||||
<Marked>{title}</Marked>
|
||||
<Marked>
|
||||
{title}
|
||||
</Marked>
|
||||
</h2>
|
||||
);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue