@quintype/seo 1.46.1-support-image-alt-text.0 → 1.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/dist/index.cjs.js +25 -4
- package/index.js +4 -4
- package/package.json +1 -1
- package/src/image-tags.js +3 -5
- package/src/structured-data/schema.js +19 -0
- package/src/structured-data/structured-data-tags.js +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.46.1](https://github.com/quintype/quintype-node-seo/compare/v1.46.0...v1.46.1) (2024-06-11)
|
|
6
|
+
|
|
5
7
|
## [1.46.0](https://github.com/quintype/quintype-node-seo/compare/v1.44.1...v1.46.0) (2024-04-18)
|
|
6
8
|
|
|
7
9
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -239,7 +239,7 @@ function getSiteTwitterHandle(config, fallback) {
|
|
|
239
239
|
function pickImageFromCard(story, cardId) {
|
|
240
240
|
const { metadata = {} } = story.cards.find(card => card.id === cardId) || {};
|
|
241
241
|
if (metadata && !lodash.isEmpty(metadata) && lodash.get(metadata, ["social-share", "image", "key"], false)) {
|
|
242
|
-
const alt = metadata["social-share"].image
|
|
242
|
+
const alt = metadata["social-share"].image.attribution || metadata["social-share"].title || metadata["social-share"].message || getAttribution(story);
|
|
243
243
|
return {
|
|
244
244
|
image: new quintypeJs.FocusedImage(metadata["social-share"].image.key, metadata["social-share"].image.metadata || {}),
|
|
245
245
|
alt
|
|
@@ -248,7 +248,7 @@ function pickImageFromCard(story, cardId) {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
function getAttribution(story) {
|
|
251
|
-
return story["hero-image-
|
|
251
|
+
return story["hero-image-attribution"] || story.summary || lodash.get(story, ["alternative", "home", "default", "headline"]) || story.headline;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
/**
|
|
@@ -270,14 +270,13 @@ function pickImageFromStory({ story, config, seoConfig }) {
|
|
|
270
270
|
const fallbackSocialImage = lodash.get(seoConfig, ["fallbackSocialImage"]);
|
|
271
271
|
const altHeroImg = getAlt("home", "hero-image-s3-key", null);
|
|
272
272
|
const altSocialHeroImg = getAlt("social", "hero-image-s3-key", null);
|
|
273
|
-
const altSocialAltText = getAlt("social", "hero-image-alt-text", getAttribution(story));
|
|
274
273
|
const storyHeroImage = lodash.get(story, ["hero-image-s3-key"]);
|
|
275
274
|
const logo_url = lodash.get(config, ["theme-attributes", "logo_url"]);
|
|
276
275
|
const logo = lodash.get(config, ["theme-attributes", "logo"]);
|
|
277
276
|
|
|
278
277
|
if (altSocialHeroImg) {
|
|
279
278
|
const metadata = getAlt("social", "hero-image-metadata", {});
|
|
280
|
-
return { image: new quintypeJs.FocusedImage(altSocialHeroImg, metadata),
|
|
279
|
+
return { image: new quintypeJs.FocusedImage(altSocialHeroImg, metadata), alt };
|
|
281
280
|
} else if (altHeroImg) {
|
|
282
281
|
const metadata = getAlt("home", "hero-image-metadata", {});
|
|
283
282
|
return { image: new quintypeJs.FocusedImage(altHeroImg, metadata), alt };
|
|
@@ -535,6 +534,24 @@ function getSchemaBreadcrumbList(breadcrumbsDataList) {
|
|
|
535
534
|
return Object.assign({}, getSchemaContext, getSchemaType("BreadcrumbList"), { itemListElement });
|
|
536
535
|
}
|
|
537
536
|
|
|
537
|
+
function generateAuthorPageSchema(publisherConfig, data, url) {
|
|
538
|
+
const sketchesHost = publisherConfig["sketches-host"];
|
|
539
|
+
const publisherName = getTitle$1(publisherConfig);
|
|
540
|
+
const authorHREF = url["href"];
|
|
541
|
+
const authorURL = `${sketchesHost}${authorHREF}`;
|
|
542
|
+
const authorName = lodash.get(data, ["author", "name"], "");
|
|
543
|
+
return {
|
|
544
|
+
name: authorName,
|
|
545
|
+
jobTitle: "Author",
|
|
546
|
+
url: authorURL,
|
|
547
|
+
worksFor: {
|
|
548
|
+
"@type": "NewsMediaOrganization",
|
|
549
|
+
name: publisherName,
|
|
550
|
+
url: sketchesHost
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
|
|
538
555
|
function getMovieEntityTags(movieJson) {
|
|
539
556
|
return getSchemaMovieReview(movieJson);
|
|
540
557
|
}
|
|
@@ -961,6 +978,10 @@ function StructuredDataTags({ structuredData = {} }, config, pageType, response
|
|
|
961
978
|
}
|
|
962
979
|
}
|
|
963
980
|
|
|
981
|
+
if (!isStructuredDataEmpty && pageType === "author-page") {
|
|
982
|
+
tags.push(ldJson("Person", generateAuthorPageSchema(publisherConfig, response.data, url)));
|
|
983
|
+
}
|
|
984
|
+
|
|
964
985
|
function generateNewsArticleTags() {
|
|
965
986
|
if (structuredData.enableNewsArticle) {
|
|
966
987
|
return ldJson("NewsArticle", Object.assign({}, articleData, generateNewsArticleData(structuredData, story, publisherConfig, pageType)));
|
package/index.js
CHANGED
|
@@ -7,15 +7,15 @@ import { generateStaticData, generateStructuredData } from "./src/generate-commo
|
|
|
7
7
|
import { ImageTags } from "./src/image-tags.js";
|
|
8
8
|
import { StaticTags } from "./src/static-tags.js";
|
|
9
9
|
import { StructuredDataTags } from "./src/structured-data/structured-data-tags.js";
|
|
10
|
-
import {
|
|
10
|
+
import { TextTags, getTitle } from "./src/text-tags.js";
|
|
11
11
|
|
|
12
12
|
export {
|
|
13
|
-
TextTags,
|
|
14
|
-
StaticTags,
|
|
15
13
|
AuthorTags,
|
|
16
14
|
ImageTags,
|
|
17
|
-
|
|
15
|
+
StaticTags,
|
|
18
16
|
StoryAmpTags,
|
|
17
|
+
StructuredDataTags,
|
|
18
|
+
TextTags,
|
|
19
19
|
generateStaticData,
|
|
20
20
|
generateStructuredData,
|
|
21
21
|
};
|
package/package.json
CHANGED
package/src/image-tags.js
CHANGED
|
@@ -6,7 +6,6 @@ function pickImageFromCard(story, cardId) {
|
|
|
6
6
|
const { metadata = {} } = story.cards.find((card) => card.id === cardId) || {};
|
|
7
7
|
if (metadata && !isEmpty(metadata) && get(metadata, ["social-share", "image", "key"], false)) {
|
|
8
8
|
const alt =
|
|
9
|
-
metadata["social-share"].image["alt-text"] ||
|
|
10
9
|
metadata["social-share"].image.attribution ||
|
|
11
10
|
metadata["social-share"].title ||
|
|
12
11
|
metadata["social-share"].message ||
|
|
@@ -20,8 +19,8 @@ function pickImageFromCard(story, cardId) {
|
|
|
20
19
|
|
|
21
20
|
function getAttribution(story) {
|
|
22
21
|
return (
|
|
23
|
-
story["hero-image-
|
|
24
|
-
story.summary ||
|
|
22
|
+
story["hero-image-attribution"] ||
|
|
23
|
+
story.summary ||
|
|
25
24
|
get(story, ["alternative", "home", "default", "headline"]) ||
|
|
26
25
|
story.headline
|
|
27
26
|
);
|
|
@@ -46,14 +45,13 @@ function pickImageFromStory({ story, config, seoConfig }) {
|
|
|
46
45
|
const fallbackSocialImage = get(seoConfig, ["fallbackSocialImage"]);
|
|
47
46
|
const altHeroImg = getAlt("home", "hero-image-s3-key", null);
|
|
48
47
|
const altSocialHeroImg = getAlt("social", "hero-image-s3-key", null);
|
|
49
|
-
const altSocialAltText = getAlt("social", "hero-image-alt-text", getAttribution(story));
|
|
50
48
|
const storyHeroImage = get(story, ["hero-image-s3-key"]);
|
|
51
49
|
const logo_url = get(config, ["theme-attributes", "logo_url"]);
|
|
52
50
|
const logo = get(config, ["theme-attributes", "logo"]);
|
|
53
51
|
|
|
54
52
|
if (altSocialHeroImg) {
|
|
55
53
|
const metadata = getAlt("social", "hero-image-metadata", {});
|
|
56
|
-
return { image: new FocusedImage(altSocialHeroImg, metadata),
|
|
54
|
+
return { image: new FocusedImage(altSocialHeroImg, metadata), alt };
|
|
57
55
|
} else if (altHeroImg) {
|
|
58
56
|
const metadata = getAlt("home", "hero-image-metadata", {});
|
|
59
57
|
return { image: new FocusedImage(altHeroImg, metadata), alt };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { get } from "lodash";
|
|
2
|
+
import { getTitle } from "../generate-common-seo";
|
|
2
3
|
import { stripMillisecondsFromTime } from "../utils";
|
|
3
4
|
export const getSchemaContext = { "@context": "http://schema.org" };
|
|
4
5
|
|
|
@@ -132,3 +133,21 @@ export function getSchemaBreadcrumbList(breadcrumbsDataList) {
|
|
|
132
133
|
);
|
|
133
134
|
return Object.assign({}, getSchemaContext, getSchemaType("BreadcrumbList"), { itemListElement });
|
|
134
135
|
}
|
|
136
|
+
|
|
137
|
+
export function generateAuthorPageSchema(publisherConfig, data, url) {
|
|
138
|
+
const sketchesHost = publisherConfig["sketches-host"];
|
|
139
|
+
const publisherName = getTitle(publisherConfig);
|
|
140
|
+
const authorHREF = url["href"];
|
|
141
|
+
const authorURL = `${sketchesHost}${authorHREF}`;
|
|
142
|
+
const authorName = get(data, ["author", "name"], "");
|
|
143
|
+
return {
|
|
144
|
+
name: authorName,
|
|
145
|
+
jobTitle: "Author",
|
|
146
|
+
url: authorURL,
|
|
147
|
+
worksFor: {
|
|
148
|
+
"@type": "NewsMediaOrganization",
|
|
149
|
+
name: publisherName,
|
|
150
|
+
url: sketchesHost,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
@@ -2,6 +2,7 @@ import get from "lodash/get";
|
|
|
2
2
|
import { getQueryParams, stripMillisecondsFromTime } from "../utils";
|
|
3
3
|
import { generateTagsForEntity } from "./entity";
|
|
4
4
|
import {
|
|
5
|
+
generateAuthorPageSchema,
|
|
5
6
|
getSchemaBlogPosting,
|
|
6
7
|
getSchemaBreadcrumbList,
|
|
7
8
|
getSchemaContext,
|
|
@@ -486,6 +487,10 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
|
|
|
486
487
|
}
|
|
487
488
|
}
|
|
488
489
|
|
|
490
|
+
if (!isStructuredDataEmpty && pageType === "author-page") {
|
|
491
|
+
tags.push(ldJson("Person", generateAuthorPageSchema(publisherConfig, response.data, url)));
|
|
492
|
+
}
|
|
493
|
+
|
|
489
494
|
function generateNewsArticleTags() {
|
|
490
495
|
if (structuredData.enableNewsArticle) {
|
|
491
496
|
return ldJson(
|