Skip to content

Commit

Permalink
chore: update dist for og:image:alt support
Browse files Browse the repository at this point in the history
  • Loading branch information
totto2727 committed Mar 2, 2024
1 parent f0164c5 commit 4fdf747
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions dist/lib/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ const fields = [
property: 'og:image:url',
fieldName: 'ogImageURL',
},
{
multiple: true,
property: 'og:image:alt',
fieldName: 'ogImageAlt',
},
{
multiple: true,
property: 'og:image:secure_url',
Expand Down
7 changes: 5 additions & 2 deletions dist/lib/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const mediaMapper = (item) => ({
type: item[3],
url: item[0],
width: item[1],
alt: item[4],
});
const mediaSorter = (a, b) => {
if (!(a.url && b.url)) {
Expand Down Expand Up @@ -79,7 +80,8 @@ function mediaSetup(ogObject) {
|| ogObject.ogImageProperty
|| ogObject.ogImageWidth
|| ogObject.ogImageHeight
|| ogObject.ogImageType) {
|| ogObject.ogImageType
|| ogObject.ogImageAlt) {
ogObject.ogImageSecureURL = ogObject.ogImageSecureURL ? ogObject.ogImageSecureURL : [];
ogObject.ogImageURL = ogObject.ogImageURL ? ogObject.ogImageURL : [];
ogObject.ogImageProperty = ogObject.ogImageProperty ? ogObject.ogImageProperty : [];
Expand All @@ -91,9 +93,10 @@ function mediaSetup(ogObject) {
ogObject.ogImageWidth = ogObject.ogImageWidth ? ogObject.ogImageWidth : [];
ogObject.ogImageHeight = ogObject.ogImageHeight ? ogObject.ogImageHeight : [];
ogObject.ogImageType = ogObject.ogImageType ? ogObject.ogImageType : [];
ogObject.ogImageAlt = ogObject.ogImageAlt ? ogObject.ogImageAlt : [];
}
// format images and limit to 10
const ogImages = zip(ogObject.ogImageProperty, ogObject.ogImageWidth, ogObject.ogImageHeight, ogObject.ogImageType)
const ogImages = zip(ogObject.ogImageProperty, ogObject.ogImageWidth, ogObject.ogImageHeight, ogObject.ogImageType, ogObject.ogImageAlt)
.map(mediaMapper)
.filter((value) => value.url !== undefined && value.url !== '')
.filter((value, index) => index < 10)
Expand Down

0 comments on commit 4fdf747

Please sign in to comment.