mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
Add alt tags to images for a11y (#529)
- Add imageAlt to GridBlock - Set alt equal to `user.caption` for mapped users - Set alt equal to `post.author` for blog posts - Update documentation
This commit is contained in:
parent
fc6e3b7311
commit
c2cd169b64
10 changed files with 33 additions and 18 deletions
|
@ -29,11 +29,11 @@ class GridBlock extends React.Component {
|
|||
|
||||
const topLeftImage =
|
||||
(block.imageAlign === 'top' || block.imageAlign === 'left') &&
|
||||
this.renderBlockImage(block.image, block.imageLink);
|
||||
this.renderBlockImage(block.image, block.imageLink, block.imageAlt);
|
||||
|
||||
const bottomRightImage =
|
||||
(block.imageAlign === 'bottom' || block.imageAlign === 'right') &&
|
||||
this.renderBlockImage(block.image, block.imageLink);
|
||||
this.renderBlockImage(block.image, block.imageLink, block.imageAlt);
|
||||
|
||||
return (
|
||||
<div className={blockClasses} key={block.title}>
|
||||
|
@ -47,20 +47,20 @@ class GridBlock extends React.Component {
|
|||
);
|
||||
}
|
||||
|
||||
renderBlockImage(image, imageLink) {
|
||||
renderBlockImage(image, imageLink, imageAlt) {
|
||||
if (image) {
|
||||
if (imageLink) {
|
||||
return (
|
||||
<div className="blockImage">
|
||||
<a href={imageLink}>
|
||||
<img src={image} />
|
||||
<img src={image} alt={imageAlt} />
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div className="blockImage">
|
||||
<img src={image} />
|
||||
<img src={image} alt={imageAlt} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue